Posted in Apache Linux
Apache : custom 404 error page returns a 302 error code
First let’s look what the docs says about setting up a custom error page :
http://httpd.apache.org/docs/2.0/en/custom-error.html
If you set up your custom 404 error page pointing to a full URL like :
ErrorDocument 404 http://www.wains.be/404/index.html
You would get an error 302 code.
$ curl -I http://www.wains.be/mlfkgldk
HTTP/1.1 302 Found
Date: Sat, 21 Jul 2007 09:20:40 GMT
Server: Apache
Location: http://www.wains.be/404/index.html
Connection: close
Content-Type: text/html; charset=iso-8859-1
If you want to get the real deal :
ErrorDocument 404 /404/index.html
Then…
$ curl -I http://www.wains.be/mlfkgldk
HTTP/1.1 404 Not Found
Date: Sat, 21 Jul 2007 09:21:16 GMT
Server: Apache
Last-Modified: Sat, 21 Jul 2007 09:19:53 GMT
ETag: "594022-307-8bd8a040"
Accept-Ranges: bytes
Content-Length: 775
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Useful link :
Comments
Leave Comment
Please consider visiting the partners below if you enjoyed this article :If this post saved you time and money, please consider checking my Amazon wishlist.







The Adminblogger
At the end of your linked documentation there is the explanation for this behaviour:
“Note that the script must emit an appropriate Status: header (such as 302 Found), if the response contains a Location: header (in order to issue a client side redirect). Otherwise the Location: header may have no effect.”
Have a good weekend!