Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Using .htaccess to variably block hotlinking

Question posted by: RobertTheProgrammer (Member) on July 1st, 2008 02:22 PM
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:

Code: ( text )
  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.

Robert
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Reply
Not the answer you were looking for? Post your question . . .
183,939 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Apache Forum Contributors