1

Is there a way to serve 404 instead of 403 when matched with "deny from"?

For example:

<Files *>
order deny,allow

deny from 127.0.0.1 </Files>

This will normally server a 403. But I want to server 404.

Rohit Gupta
  • 5,096

2 Answers2

2

You can be proactive about returning 404s if you know which files will 403:

RedirectMatch 404 ".*\/\..*"

will return a 404 for all files which start with a ., such as .htaccess. I don't think this will serve as a global "transform all 403s into 404s", however.

https://stackoverflow.com/questions/1486304/is-there-a-way-to-force-apache-to-return-404-instead-of-403
https://stackoverflow.com/questions/548156/problem-redirecting-403-forbidden-to-404-not-found

Darth Android
  • 38,658
0

The only way I know how to do it is in the backend code.

On my system, access to downloadable files is done via one particular php file. This creates a page with a link that expires after a few minutes. For me, it would be easy.

If you have a backend, where access to files is routed via one or more files then you can check the ipaddress in there and raise 404.

Rohit Gupta
  • 5,096