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've disabled directory listings like so...

Options -Indexes

When I try and access a directory like this:-

I get a 403 Forbidden response.

However, I want a 404 Not Found response, so hackers can't guess my directory structure so easily. How would I do that?

share|improve this question
I realise that, but there is no point in making it easy for anyone, especially as it takes so little effort to make it harder. – Rik Heywood Feb 28 '11 at 17:22
up vote 3 down vote accepted

Enable mod_rewrite and AllowOverride in /secret. Then create .htaccess:

RewriteEngine On
RewriteBase   /secret
RewriteRule   ^$ - [R=404,L]
share|improve this answer

I've looked around the internet for an answer to a similar problem. While mod_rewrite is a possible solution, I find the best solution uses the "RedirectMatch" directive.

See StackOverflow: Problem redirecting 403 Forbidden to 404 Not Found

share|improve this answer

Use .htaccess to mask errors. See this guide:

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. This link is now dead and thus this answer is now useless – Mark Henderson Sep 26 '13 at 7:46

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.