0

Possible Duplicate:
How is anti-hotlinking done?

I have a lot of images on my site and I don`t want to let other people to use my images on their sites. Is there any way to block the use of my images from other sites, maybe with .htaccess?

0
RewriteEngine On
RewriteCond %{HTTP_REFERER}  !^$
RewriteCond %{HTTP_REFERER}  !^https?://www\.domain\.com$ [NC]
RewriteCond %{HTTP_REFERER}  !^https?://subdomain\.domain\.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://google.com/thief.png [R,NC,L]

to allow people view images:

RewriteEngine On
RewriteCond %{HTTP_REFERER}  ^$ [OR]
RewriteCond %{HTTP_REFERER}  !^https?://www\.domain\.com$ [NC]
RewriteCond %{HTTP_REFERER}  !^https?://subdomain\.domain\.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://google.com/thief.png [R,NC,L]
| improve this answer | |
  • Note: if you want to enable users to view image by typing URL in address bar, remove Second line! – undone Nov 21 '11 at 16:49
  • Only removing the second line wont allow people to view the image by typing the url directly into the address bar – Tom Knapen Nov 21 '11 at 17:07
  • @Tom you're right, I'll change the code – undone Nov 21 '11 at 17:35