views:

149

answers:

4

Does anyone know the best way to do this? Apache, tomcat, linux

+1  A: 

Try the ErrorDocument directive:

ErrorDocument 404 http://example.com/

Absolute URLs are being redirected.

Gumbo
+1  A: 

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.

lucas
+3  A: 

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.

Gabriël
+2  A: 

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.

cherouvim