|
Using htaccess to block both IPs and referrers
I could use some help from anyone who uses Surpass to host their site and has successfully re-written their htaccess file manually.
Yes, I know you can use cpanel to block particular IPs or domains. However, that doesn't seem to work for me. Even after adding particular IPs to that list, those domains are still showing up in my stats. Therefore, I'm thinking I need to block those sites *as referrers*, so that their links to my sites no longer work.
Also, now that I've edited my htaccess file myself, whenever I use cpanel to add an IP to block, it sometimes creates an error by appending the code incorrectly. So it looks like I will be doing all my htaccess editing manually from now on.
I originally edited my htaccess file to redirect (permanently) a bunch of old page links that were still showing up in search engines and creating tons of errors every day. That part of the code seems to be working just fine, and my errors have decreased significantly.
However, blocking by IP or referrer doesn't seem to be working as well. As I said above, blocking by IP doesn't keep them away (those domains are still showing up in my stats even months later). When I attempted to add blocking by referrer to the same document, it creates an error and my site won't come up at all. (It's actually a forbidden -403- error that I get, not a 500 internal server error, which is odd.)
My questions are:
1) Can I do all three things--redirect, block by IP and block by referrer--in one htaccess file? Is there any reason why doing all of these in the same file would cause a conflict?
2) Are there differences in the htaccess code depending on what kind of server is being used? If so, what should I be looking for when I search out htaccess info on the web? I'm noticing there are different versions of code for the same task and I can't find anything that tells me which I should use or why.
3) Has anyone out there managed to do this manually? All three tasks? If so, would you be willing to share a copy of your code so I could replace the IPs and referrer domains I want to block and use it?
*****
This is the code I tried to add to block referrers:
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} somedomain\.org [NC,OR]
RewriteCond %{HTTP_REFERER} somedomain\.com [NC,OR]
RewriteCond %{HTTP_REFERER} somedomain\.com [NC,OR]
RewriteRule .* - [F]
(With "somedomain" replaced with the offending domains; when I upload my htaccess file with this section added to it, under the part blocking by IP, it returns the 403 error.)
******
Thanks!
~Christina
|