469,167 Members | 2,149 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

Using .htaccess to variably block hotlinking

Hi folks,

I need to combine these two functions and I'm not sure how to go about it. I know how to use .htaccess to prevent anyone from hotlinking the images on my site.

What I basically want to do is to (1) prevent anyone, anywhere from hotlinking my images and (2) prevent anyone from MySpace from hotlinking to my site at all (whether images or otherwise).

Now I currently have my .htaccess like this:

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2. RewriteCond %{HTTP_REFERER} !^$
  3. RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
  4. RewriteRule \.(gif|jpg)$ http://www.mydomain.com/theft.jpg [L]
This prevents anyone from hotlinking gif or jpg files on my site, and instead displays the "theft.jpg" image. Works great. But how do I combine this to not allow MySpace to link to *anything* on my site, whether images or otherwise.

Thanks for any assistance you can provide.

Jul 1 '08 #1
0 1816

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Mark | last post: by
3 posts views Thread by rossputin | last post: by
reply views Thread by Stoco | last post: by
13 posts views Thread by Kantha | last post: by
7 posts views Thread by Ole Nielsby | last post: by
5 posts views Thread by Nosferatum | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.