VDS Sphera Knowledge Base
| Main / Browse Categories / Apache / How do I prevent hot linking of my pictures, movies, or other files? |
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
|
||||||||
Attachments
| No attachments. |
Related Articles
|
|


