I have a website where I’m trying to block specific IP addresses (more than one) from a directory 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? I also understand that the code below may not be the best choice but at the moment, it does work for a single page. Hopefully someone can help with a new .htaccess code to redirect multiple IP’s for a directory to my yourbanned.html page.
<files storage.html> 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 </files>