VDS Sphera Knowledge Base

Main / Browse Categories / Apache / How do I prevent hot linking of my pictures, movies, or other files?

Print article Print Article    Email article Email Article

How do I prevent hot linking of my pictures, movies, or other files?
You need to create an .htaccess file in the /var/www/html or the directory of your choice that contains the following code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://YOUR_IP_ADDRESS/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://YOUR_FIRST_DOMAIN.com/.*$     [NC]
RewriteCond %{HTTP_REFERER} !^http://www.YOUR_FIRST_DOMAIN.com/.*$  [NC]
RewriteCond %{HTTP_REFERER} !^http://YOUR_SECOND_DOMAIN.com/.*$     [NC]
RewriteCond %{HTTP_REFERER} !^http://www.YOUR_SECOND_DOMAIN.com/.*$  [NC]
RewriteRule .*.(gif|GIF|jpg|JPG)$ - [F]
For each domain that you have content, just add two lines to the .htaccess file like below:
RewriteCond %{HTTP_REFERER} !^http://YOUR_SECOND_DOMAIN.com/.*$     [NC]
RewriteCond %{HTTP_REFERER} !^http://www.YOUR_SECOND_DOMAIN.com/.*$  [NC]
Just make sure the first two lines and the last line is always the same. You may also add more to the last line for any other file type that you would like to prevent from being hot-linked (mov, asx, mpg, etc), just follow the syntax above:
(mov|MOV|asx|ASX)

User Comments
How do I prevent hot linking of my pictures, movies, or other files?  
There are no user comments for this topic.
 

Attachments
No attachments.

Related Articles
 Where is the Apache httpd.conf file located?
 How do I restart Apache?
 How can I create a Script Alias in Apache to Neomail?
 How can I prevent Directory Listing?
 How do I password protect my site?

Why Choose Our Hosting?

  • Unmatched Customer Support!
  • Virtual Private Server technology provides a rich, dedicated-like environment for every account.
  • We are known for our superb quality, performance and flexible hosting environment. We manage the server, software, and network you do the rest.
Continue reading »

Featured Hosting Plan


Learn more about our VPS Extreme

What is Included?

  • PHP 5/MySQL 5
  • Parallels® Plesk Panel 10
  • Unique IP Address
  • Daily VPS Backups (Off Server)
  • SAS Hardware Raid diskspace
  • CentOS 5 x86_64 bit
  • Multi-homed Tier 1 Bandwidth
  • Full Upgrade capabilities
Continue reading »