开发者

Redirect banned IPs to 404 rather than 403

开发者 https://www.devze.com 2023-04-12 11:45 出处:网络
I have a certain directory I only want a开发者_如何学运维ccessible from within my office.I have this working, and blocked just fine.Here is what I have in my apache conf:

I have a certain directory I only want a开发者_如何学运维ccessible 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


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


To change all 403,400 errors into 404 errors, put this at the end of /etc/apache2/conf.d/localized-error-pages OR into a .htaccess OR into your <Directory /usr/share/phpmyadmin>

# Will raise a 404 error, because the file <fake_file_for_apache_404.php> doesn't exist.
# We change 403 or 400 to 404 !
ErrorDocument 400 /fake_file_for_apache_404.php
ErrorDocument 403 /fake_file_for_apache_404.php
# We need to rewrite 404 error, else we will have "fake_file_for_apache_404.php not found"
ErrorDocument 404 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL <script type=\"text/javascript\">document.write(document.location.pathname);</script> was not found on this server.</p></body></html>"
ErrorDocument 500 "Server in update. Please comme back later."
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号