Stopping hotlinks from a site and all it's subdomains?

Fix it!!

Stopping hotlinks from a site and all it's subdomains?

Postby Light Speed » Sun Jul 13, 2008 4:36 am

A blog site in another county has a bunch of it's members hotinking from my site.

I have tried stopping them but my syntax must be wrong because it only stops some of them.

The site is blog.cz and the members each have their own subdomain like this

somebody.blog.cz
somebody-else.blog.cz

my code below is replacing my image with one from the main blog at blog.cz and it is working for somebody.blog.cz but not for somebody-else.blog.cz probably because of the hyphen. How do I account for that in my code?


Code: Select all
RewriteCond %{HTTP_REFERER} ^http://([a-z0-9]+\.)?blog\.cz(/.*)?$ [NC]

RewriteRule ^store/files/images/(.*)$ http://nd.blog.cz/b/blog.blog.cz/obrazky/30824732.jpg [L]



I also want anybody who is not from blog.cz who tries to hotlink to get a banner from my site:
Code: Select all
RewriteRule ^store/files/images/(.*)$  Banners/redirect_banner.gif [L,R=301]


How can I accomplish both of these at the same time?
Light Speed
 
Posts: 3
Joined: Sun Jul 13, 2008 4:18 am

Postby richardk » Sun Jul 13, 2008 10:52 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blog\.cz(/.*)?$ [NC]
RewriteRule ^store/files/images/(.*)$ http://nd.blog.cz/b/blog.blog.cz/obrazky/30824732.jpg [L]

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com(/.*)?$ [NC]
RewriteRule ^store/files/images(/.*)?$ /Banners/redirect_banner.gif [R,L]

Where example.com is your domain.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Security with Mod_Rewrite

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron