Forum Moderators: phranque

Message Too Old, No Replies

block all subdomains using .htaccess

htaccess, referring subdomains

         

chiquin

1:58 am on Dec 31, 2008 (gmt 0)

10+ Year Member



Hello everyone.
good I use wordpress, I'm experiencing is an atack of a sub domain, but I always lock this sub domain is changed, is not how I block all subdomains of this domain?

I mean, all that matters is creator, because when I block some, is a new sub domain creator.

when I'm using this code:


RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} #*$!\.AAA\.com\.tt [NC,OR]
RewriteCond %{HTTP_REFERER} #*$!\.AAA\.URL2\.com\.tt
RewriteRule .* - [F]

and

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?#*$!.AAA.com.*$ [NC]
#RewriteRule .* [bbbbbb.bb...] [R,L]
RewriteRule ^.*$ [127.0.0.1...] [L,R=301]

more when I lock the sub #*$! domain is a new creative field in sub AAA.

thanks!

chiquin

2:01 am on Dec 31, 2008 (gmt 0)

10+ Year Member




RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} #*$!\.AAA\.com\.tt [NC,OR]
RewriteCond %{HTTP_REFERER} www\.#*$!\.AAA\.com\.tt
RewriteRule .* - [F]

and

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?#*$!.AAA.com.tt.*$ [NC]
#RewriteRule .* http://www.kkkkkkkkk.tt [R,L]
RewriteRule ^.*$ http://127.0.0.1/ [L,R=301]

jdMorgan

2:18 am on Dec 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteEngine on
#
# Block all http and https referrals from "example.com" and all subdomains of "example.com"
RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*example\.com [NC]
RewriteRule .* - [F]

Jim

chiquin

2:26 am on Dec 31, 2008 (gmt 0)

10+ Year Member




ok, thanks.

I put this, correct? I am layman in the subject.


RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://([^.]+\.).example.com.tt.*$ [NC]
#RewriteRule .* http://www.exampe.tt [R,L]
RewriteRule ^.*$ http://127.0.0.1/ [L,R=301]

more is needed I change that code? do not need another change in neither?

chiquin

2:30 am on Dec 31, 2008 (gmt 0)

10+ Year Member



good, and I am very layman, I put all my. htaacess is yes you can edit it to show me the correct ok? I am very grateful.

# BEGIN WordPress

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} subdomain\.example\.com\.tt [NC,OR]
RewriteCond %{HTTP_REFERER} www\.subdomain\.example\.com\.tt
RewriteRule .* - [F]

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

# END WordPress

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://([^.]+\.).example.com.tt.*$ [NC]
#RewriteRule .* http://www.example2.tt [R,L]
RewriteRule ^.*$ http://127.0.0.1/ [L,R=301]

Thank you for your help.

jdMorgan

2:44 am on Dec 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



all my .htaccess is yes you can edit it to show me the correct ok

All your .htaccess is:


RewriteEngine on
#
RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*example\.com\.tt [NC]
RewriteRule .* - [F]
#
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Jim

[edited by: jdMorgan at 2:46 am (utc) on Dec. 31, 2008]

chiquin

3:00 am on Dec 31, 2008 (gmt 0)

10+ Year Member



you, you have more certainty that only necessary and that?

I get that many visits referer per second.

I would not put this code:


([^.]+\.)

this line?


RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} cds\example\.com\.tt [NC,OR]
RewriteCond %{HTTP_REFERER} www\.cds\.blogger\.com\.tt
RewriteRule .* - [F]

good, I use this, if I understand a problem I notice on the topic ok?

thank you very much!

jdMorgan

4:00 pm on Dec 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you do not use "^https?://([^.]+\.)*cds\.example\.com\.tt" and start-anchor the pattern, then you risk having your code mis-behave if the query string contains a reference to that 'bad' site, even though the referring domain is not that 'bad' site.

For example, your code will break if the referrer is
"http://www.google.com/search?q=who+owns+the+cds.example.com.tt+domain%3f"
Here, the referrer is actually google, but your code will reject the request because you did not effectively anchor the pattern to the beginning of the referrer string.

That "([^.]+\.)*" sub-pattern simply means "match zero or more occurrences of ( one or more characters not a period {full stop}, followed by a period ). It therefore matches zero or more "subdomain levels" at the beginning of the hostname -- Such as "<anything><period><anything><period>cds\.example\.com\.tt"

Jim