0

I am looking to send the 404 error code when users try to access forbidden directories. I have the 'deny from all' attched to all private directories, and the following errordocs on the main .htaccess file:

ErrorDocument 404 /404/
ErrorDocument 403 /404/

This sends users to the custom 404 page I have set up, but when I check the request headers, it's still sending a 403 error code. Can I pass a 404 error code through the .htaccess file on forbidden directories?

[Copied over from stackoverflow]

5

not a straight answer, but if you have php [ or other server side include scripting ] installed - you can use:

ErrorDocument 403 /404.php

and in 404.php have:

<?php
  header("HTTP/1.0 404 Not Found");
  //...
1

Try using RedirectMatch, like this:

RedirectMatch   404     ^/phpmyadmin(/.*)?$
RedirectMatch   404     ^/server-status(/.*)?$

but you sould write one line per resource to "hide"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.