301 all 404s to homepage
-
03-07-2019 - |
Question
Does anyone know the best way to do this? Apache, tomcat, linux
Solution
Also the tomcat way: stick in web.xml:
<error-page>
<error-code>404</error-code>
<location>/homepage.html</location>
</error-page>
Relative to web apps context.
OTHER TIPS
Don't, unless is really a permantent move. Otherwise, return 404.
Telling anyone your 404 page is 301, means it would show the actual content related to the URL that was asked for. Important for SEO.
404s should be 404s. Design a good and usable 404 page with appropriate message, link back to homepage, search form and auto discovered possible related pages.
The Smashing Magazine has a very good article on designing 404 pages.
Try the ErrorDocument
directive:
ErrorDocument 404 http://example.com/
Absolute URLs are being redirected.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow