Using .htaccess to variably block hotlinking

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RobertTheProgrammer
    New Member
    • Aug 2007
    • 58

    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:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
    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
Working...