[Resolved] Ban Hotlinking via htaccess

Discussion in 'General' started by jkeegan, Mar 20, 2010.

  1. jkeegan

    jkeegan Active Member

    As per this doc:


    I am trying to ban specific domains from hotlinking using this:

    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
    But that's not working... Do I need to do something different in litespeed?
    Last edited by a moderator: Mar 21, 2010
  2. mistwang

    mistwang LiteSpeed Staff

    It should work well.

    RewriteCond %{HTTP_REFERER} ^[URL="http://%28.+%5C.%29/?%28myspace%7Cblogspot%7C%5C.com/"]http://(.+\.)?(myspace|blogspot|[/URL][URL="http://%28.+%5c.%29/?livejournal%5C.com/"]livejournal)[/URL][URL="http://%28.+%5C.%29/?%28myspace%7Cblogspot%7C%5C.com/"]\.com/[/URL] [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
    is more efficient
    Have you enabled rewrite in .htaccess? You can trouble shoot it by enabling rewrite log.
  3. jkeegan

    jkeegan Active Member

    RewriteEngine on and rewrite log doesn't seem to tell me anything... Site is real busy so rewrite log went to 1 GB in minutes so it's hard to find anything in there...
  4. NiteWave

    NiteWave Administrator

    can you post 1~3 lines of access log which still access the image files from myspace etc? so we can analyze why the rewrite rule not working?
  5. jkeegan

    jkeegan Active Member

    OK, I was using those hosts to protect the client's privacy. They were trying to block other hosts than myspace. I will send in a ticket. Thank you.
  6. mistwang

    mistwang LiteSpeed Staff

    does it work as expected with Apache?
  7. jkeegan

    jkeegan Active Member

    Looks like the rule is fine, the files were just being caught by some rule earlier in the chain... When I moved them to the top of the file it worked fine.


Share This Page