404handler icon indicating copy to clipboard operation
404handler copied to clipboard

Redirect to static files without file extensions and query parameters adds trailing slash

Open t-my opened this issue 4 years ago • 1 comments

Old url

/static/css/bundle (without a .css extension)

New url

https://newsite.com/static/css/bundle

Redirect without query parameters work as intended:

/static/css/bundle -> https://newsite.com/static/css/bundle

If you add a queryparameter, redirect will add trailing slash to the redirected address:

/static/css/bundle?p=123 -> https://newsite.com/static/css/bundle/?p=123

naturally causing 404 because the server thinks this is a path, not a file.

t-my avatar Oct 08 '20 07:10 t-my

Why do you need a 404 handler to handle static files? The 404 handler was not intended for the page's static file redirects. You should use the correct URL on the page instead. The reason why slash is added to the end of URL when there is no extension - to make URLs the same. Editors often added the same URL with and without a slash at the end and it caused a lot of problems.

marisks avatar Dec 11 '20 14:12 marisks