Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

htaccess and anit-hotlinking

Ok, so I'm pretty new to extensive screwing with the htaccess file. However, I am in need of a bit of assistance.

I currently have been having a lot of problems with people hotlinking to various files on my site. A fellow webmaster send me an example of what to put inside my htaccess file to stop that, and it worked just fine. However, now I need to ALLOW hotlinking to one directory, but nothing else on the domain. Here is what I have that my friend sent me:

AuthUserFile /dev/null
AuthGroupFile /dev/null

RewriteEngine On
        RewriteCond %{HTTP_REFERER} !^$
        RewriteCond %{HTTP_REFERER} !^(Link: http://www.mydomain.com/.*$)http://www.mydomain.com/.*$ [NC]
        RewriteCond %{HTTP_REFERER} !^(Link: http://www.mydomain.com:80/.*$)http://www.mydomain.com:80/.*$ [NC]
        RewriteCond %{HTTP_REFERER} !^(Link: http://mydomain.com/.*$)http://mydomain.com/.*$ [NC]
        RewriteCond %{HTTP_REFERER} !^(Link: http://mydomain.com:80/.*$)http://mydomain.com:80/.*$ [NC]
        RewriteCond %{HTTP_REFERER} !^(Link:*$)*$ [NC]
        RewriteCond %{HTTP_REFERER} !^(Link:*$)*$ [NC]
        RewriteRule .*[Jj][Pp][Gg]$|.*[Gg][Ii][Ff]$ (Link: http://www.mydomain.com/)http://www.mydomain.com/ [R,L]

So basically, I need to keep this intact, but ALLOW hotlinking to http://www.mydomain.com/hotlinking/ for instance. Any insight? I'd offer more than 100 points on this, but that's all I have right now.
1 Solution
Hi Thora Fan,

If you are interested to block hot-linking to all your sits, while allowing to a specific directory;

you could have a separate <Directory> or <Location> tag for the specified resources and allow hotlinking there.

some related PAQ.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now