sourcecode

Monday, July 2, 2012

Customize 404 page for subfolders

The 404 not found page can be customized after configure the /etc/httpd/conf/httpd.conf (for Fedora) by uncomment:
ErrorDocument 404 /missing.html
Normally when a webpage requested under root folder does not exist, the missing.html will be corrected displayed. If the missing.html is missing too, you get a double 404 error.

One little thing to notice is that even though the missting.html is under root, when it is invoked from a subfolder, the browser would believe it is from that subfolder and the relative paths in the missing.html would be broken, such as CSS and images.

A quick remedy for this is using absolute paths (start with /) in the missing.html.

This problem was solved by observing the error_log under /etc/httpd/logs


No comments: