htaccess and anit-hotlinking

Posted on 2003-03-30
Medium Priority
Last Modified: 2010-04-20
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.
Question by:Thora_Fan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 15

Accepted Solution

samri earned 400 total points
ID: 8267555
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question