404handler
404handler copied to clipboard
Redirect to static files without file extensions and query parameters adds trailing slash
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.
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.