Sunday, October 19, 2008

Configure 404 on Apache and Tomcat

Its simple.

To configure custom error pages on apache,
in your virtual host configuration

<virtualhost 127.0.0.1:80>
DocumentRoot /www/example1
ServerName www.example1.com

ErrorDocument 404 /errordocs/404.html

</virtualhost>

And in tomcat, have something like

<web-app>
<error-page>
<error-code>404</error-code>
<location>/error404.jsp</location>
</error-page>
...
<web-app>

in your web.xml