Click to See Complete Forum and Search --> : Using htaccess to redirect IP from page
We have a spammer abusing one of our forms, so I'd like to use an htaccess file to redirect his IP address whenever he tries to access that one page only.
The online tutorials that I've read talk about redirecting *everyone* from one page address to another; or, blocking a certain IP from an entire site, but no one that I've found has explained how to simply redirect a specific IP away from a specific page using htaccess (so perhaps it is not possible??).
In capturing his IP I've found that the first 2 sets of digits remain constant, as in: 220.224.*
So I'm wondering how can I redirect 220.224.* away from "emailform.html" and to "error.html whenever he tries to access the form?
Thanks for any advice...
BrainDonor
03-22-2005, 02:45 PM
Why not just ban his name/IP from the forum completely?
edit: nevermind...I read that too fast and thought you said "forum" not "form".
Scleppel
03-22-2005, 04:26 PM
This isn't guaranteed to work...
<files emailform.html>
ErrorDocument 403 error.html
Order Allow,Deny
Allow from All
Deny form 220.224
</files>
It should block the ip with a 403 error (i think it's 403) and you have them sent to error.html instead of the default.
Thanks Scleppel -- hopefully if that's not exactly correct we'll get someone to jump in and help out. I appreciate your feedback...
Scleppel... Last night I decided to create a new temporary folder at my hosting service, put in the various files, and tested your suggested htaccess with my own IP address -- it kept me away from the target page. The only thing it didn't do is redirect me to error.html, so I read some htaccess tutorials and found that everyone did it the same way you said, so perhaps it is a glitch with that server. Thanks again for your help... :D <files emailform.html>
ErrorDocument 403 error.html
Order Allow,Deny
Allow from All
Deny from 220.224
</files>
Scleppel
03-23-2005, 10:57 AM
try different paths to the error.html, like
ErrorDocument 403 /you_folder/error.html
I had tried that last night, along with the full url (http://...etc) and the full pathway (/home/foomanchu/public_html/...etc), but nothing seemed to work.
I ended up using ErrorDocument 404, which gives me a "Forbidden" message plus the "You don't have permission to access..." and also "Additionally, a 404 Not Found error was encountered...".
Believe me, I'm thrilled with that -- the error.html redirect was something I thought I might want, but as long as I can keep the spammer out then this works just as well...
asrekdal
07-19-2006, 10:06 PM
A little late on this posting... but my help others landing from google, etc..
This should display the 403 error document.
<files document_to_block.php>
ErrorDocument 403 /document_to_show.html
Order Allow,Deny
Allow from All
Deny from xxx.xxx.xxx.xxx
</files>
Notice the forward slash "/" before the error document.
Regards,
Andrew
shane.carr
07-26-2006, 12:48 AM
Your problem is that the file is not relative. For example,
/errors/error403.html
is, on your server,
http://www.example.com/errors/error403.html
I know that this thread is from March 2005, but if you still get email notification, you should still recieve this tip ;)