Some websites retain the URL path when a path is accessed that isn't found and when the page loads they simply display an error title, message and also set the HTTP status code to 404.
Other pages redirect it to a fixed 404 URL path which displays both the content and the header.
My questions are:
Or is it better to return a 404 response and include a location header pointing to the dedicated 404 URL (I'm not sure if its possible to mix redirections and 400-series status codes)?
If the page that your server is returning is a "File Not Found", it should return a 404 error. Adding in a redirect seems pointless and confusing to web-crawlers and people alike.
With Apache you can retain the original URL, return a 404 and have a custom error message if you add this to your .htaccess file in the root of your webserver:
ErrorDocument 404 /notfound.html
Where notfound.html is your custom error page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With