Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've disabled directory listings like so...

Options -Indexes

When I try and access a directory like this:-

www.example.com/secret/

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
add comment

3 Answers

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
add comment

Use .htaccess to mask errors. See this guide:

http://www.tarahost.net/pages/web-design/29371.php

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
add comment

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
add comment

Your Answer

 
discard

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.