views:

46

answers:

2

My web server is Apache. I have disabled directory listings via an Options -Indexes directive in a .htaccess file, so if a user navigates to a directory without an index.html file, he'll get a 403 Forbidden error. However, I'd like to return 404 Not Found in such instances instead. Is that possible?

A: 

You can try using mod_rewrite for it:

RewriteEngine On  RewriteRule
my_hidden_dir.* not_found.php
Sam Dark
A: 

You can use

ErrorDocument 403 /path/to/your/error/file/or/script

to override 403 with your own script, and make it return 404. for example, in PHP:

<?php
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
?>
Ofri Raviv