Stopping Hotlinking

Soldato
Joined
18 Oct 2002
Posts
5,586
Location
Stone, Staffordshire
When I look at my refers I see that Google Images is a my second most popular site. I've found sites that are hotlinking directly to my pictures.

All of my photos have either been purchased from istockphoto or gained from flickr users with ther permission and credit. I'd there like to stop people being able to link to photos on my hosting.

1) How can I stop it in the first place
2) If people do hotlink I'd link to replace the image they are trying to link with an alternative.

Any help greatly appreciated.
 

Thanks for that.

I have opened my existing .htaccess file and it contains this already. Where do I stick this new bit of code?

Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
 
put this bit (obviously modified to suit your website), just after the RewriteEngine On
as you prob want this to be done before the other rules.

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?somesite.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ http://www.somesite.com/nasty.gif [R,L]
 
Ok tried inserting

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?the-pier.co.uk/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ http://www.the-pier.co.uk/hotlink.gif [R,L]

But a) although it did remove the linked image it didn't display my hotlink one?!
b) Can I tie the restriction down to pictures in a certain directory instead of my entire domain?

I have sub folders for ebay, ocuk and wordpress and I want the wordpress one locked out
 
Back
Top Bottom