Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking to send the 404 error code when users try to access forbidden directories. I have the 'deny from all' attched to all private directories, and the following errordocs on the main .htaccess file:

ErrorDocument 404 /404/
ErrorDocument 403 /404/

This sends users to the custom 404 page I have set up, but when I check the request headers, it's still sending a 403 error code. Can I pass a 404 error code through the .htaccess file on forbidden directories?

[Copied over from stackoverflow]

share|improve this question
up vote 3 down vote accepted

not a straight answer, but if you have php [ or other server side include scripting ] installed - you can use:

ErrorDocument 403 /404.php

and in 404.php have:

  header("HTTP/1.0 404 Not Found");
share|improve this answer
Good enough for me, thanks=). – Corey Hart Sep 15 '09 at 10:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.