Reputation: 410762
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?
Upvotes: 1
Views: 944
Reputation: 24823
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");
?>
Upvotes: -1
Reputation: 5291
You can try using mod_rewrite for it:
RewriteEngine On RewriteRule
my_hidden_dir.* not_found.php
Upvotes: 0