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?
views:
46answers:
2
A:
You can try using mod_rewrite for it:
RewriteEngine On RewriteRule
my_hidden_dir.* not_found.php
Sam Dark
2010-02-23 18:11:11
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
2010-02-23 18:50:00