Forum Moderators: phranque

Message Too Old, No Replies

How to block all *.tk domains

         

testing0

1:26 pm on Jun 5, 2007 (gmt 0)

10+ Year Member



hi,

was wondering if its possible to write a rule in htaccess to block all kind of reffers from .tk domains?

as they use some kinda special script that disable my fram buster so only way i think is to block their reffereers.

any help would be appreciated.

regards,

jdMorgan

2:07 pm on Jun 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteCond %{HTTP_REFERER} ^http://([^./]\.)+tk(:[0-9]+)/
RewriteRule .* - [F]

Here we look for any domain or subdomain in the .tk TLD, followed by an optional port number and a slash, and forbid access if we get a match. All the extra regex stuff is to avoid "finding" an occurrence of ".tk" in any part of the referrer except the initial part. For example, if ".tk" appears in a query string of a referrer URL from a .com host then it should not be blocked, so the regex pattern above will prevent it from being blocked.

If you use a custom 403 error document, add a RewriteCond to this rule to exclude your ErrorDocument URL from being rewritten, in order to avoid an 'infinite' loop:


RewriteCond %{REQUEST_URI} !/path-to-your-403-ErrorDocument
RewriteCond %{HTTP_REFERER} ^http://([^./]\.)+tk(:[0-9]+)/
RewriteRule .* - [F]

Jim