The Way to Programming
The Way to Programming
have a website where I’m trying to block specific IP addresses (more than one) from a specific folder and send them to a specific page on my website where I have created a special message for them.
In the code below, when the visitor with the IP address listed tries to access the page storage.html, they are sent to a page that lets them know why I banned them. However, what I really want to do is block their access to the the directory /myfiles and when they click any link on my website that leads to any file within this directory, they are sent to the yourbanned.html file. How would I write that and would it be placed in the root directory on in the directory that I want to block access to for the specific IP addresses?
ErrorDocument 403 http://www.mywebsite/yourbanned.html Order Allow,Deny Allow from All Deny from xx.xx.xx.xx Deny from xx.xx.xx.xx Deny from xx.xx.xx.xx Deny from xx.xx.xx.xx
Checked out this site? Looks like it solves the problem pretty well.
http://perishablepress.com/permanently-redirect-a-specific-ip-request-for-a-single-page-via-htaccess
Isn’t that easily fixed by changing it slightly?
RewriteCond %{REQUEST_URI} /requested-page\.html$
Becomes
RewriteCond %{REQUEST_URI} ^/requested-directory/$
I’m no expert on htaccess syntax, so I could be slightly off. But the script does what you want. You only need to find how to use request_uri with folders.
Sign in to your account