Search code examples
apachehttp-redirecthttp-status-code-403

Redirect banned IPs to 404 rather than 403


I have a certain directory I only want accessible from within my office. I have this working, and blocked just fine. Here is what I have in my apache conf:

<Directory /var/www/html/live/protected>
  Order deny,allow
  allow from 1.1.1.1.1.1 # My office ip
  deny from all
</Directory>

Rather than create a custom 403 page, I would rather just send these people to 404 pages. Is there a way in Apache I can have a conditional that if they are not coming from my office IP, I can just send them to the 404 page I have?

Thanks


Solution

  • Maybe this can help:

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

    -> Is there a way to force apache to return 404 instead of 403?
    -> Problem redirecting 403 Forbidden to 404 Not Found