icon Learn how to get the most out of Surmunity - read our forum tips here! | Welcome! Please register to access all of our features.
Old January 4th, 2008, 2:50 PM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Jun 2004
17 posts
Gave thanks: 0
Thanked 0 times
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
hypchick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 4th, 2008, 4:03 PM   #2 (permalink)
He shoots.. He scores!
Super #1
 
puckchaser's Avatar
 
Joined in Feb 2007
Lives in A room with no windows.
Hosted on SH110
1,361 posts
Gave thanks: 40
Thanked 129 times
Take a look at this page.. It has ALOT of different ways to block via .htaccess

http://www.aaronlogan.com/downloads/htaccess.php
__________________
SH110
puckchaser is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 4th, 2008, 5:33 PM   #3 (permalink)
Registered User
Fresh Surpasser
 
Joined in Jun 2004
17 posts
Gave thanks: 0
Thanked 0 times
Still looking...also getting new error

Quote:
Originally Posted by puckchaser View Post
Take a look at this page.. It has ALOT of different ways to block via .htaccess

http://www.aaronlogan.com/downloads/htaccess.php
Thanks, but that one still doesn't illustrate using all three in the same file: blocking by referrer (domain) and IP address plus redirecting.

Also, I am getting this error in my error log now:

"Redirect takes two or three arguments, an optional status, then document to be redirected and destination URL"

Anyone...?
hypchick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old January 4th, 2008, 5:37 PM   #4 (permalink)
URB4N 5K1LLZ
Super #1
 
Roxy's Avatar
 
Joined in Sep 2005
Lives in Orlando, FL
Hosted on SH63
2,648 posts
Gave thanks: 81
Thanked 127 times
Sorry, wish I could help. I don't do much with my .htaccess. If I find anything, I'll be sure to post it.
__________________
Roxanne
Surpass Staff

Urban Roxy -Personal Blog
SH63 - the best darn shared server!
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On