Forum Moderators: phranque

Message Too Old, No Replies

custom 404 page for specific directory

         

blaketar

7:50 pm on Jun 1, 2006 (gmt 0)

10+ Year Member



Is it possible to create a custom 404 not found page specific to a directory?

Meaning if a user went to: example.com/articles/dsaskdsd.html they would get example.com/articles/404.html

and if they went to: example.com/downloads/kkdsks.html they would get example.com/downloads/404.html

A custom 404 page designed for the specific directory instead of the site-wide 404 notfound-page?

Thanks!

jdMorgan

8:00 pm on Jun 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put the following in a plain-text file named .htaccess into that subdirectory:

ErrorDocument 404 /articles/404.html

Then put your custom error document in that same directory. Note that this is not a requirement, you can put it anywhere that's HTTP-accessible. But the local path in the ErrorDocument directive above must point to it.

Warning: Do not use a full URL in the ErrorDocument directive; If you do, your server will return a 302-Found response, instead of a 404-Not Found. See Apache ErrorDocument [httpd.apache.org] for details.

Jim