Add to Favourites Add to Favourites    Print this Article Print this Article

Hotlink protection: How-To prevent people from stealing your files

Create an .htaccess file in your public_html directory with the following code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?domain.com.*$ [NC]
RewriteRule .(gif|jpg)$ - [F]

Where domain.com is your domain.

Similarly, you can set this up to allow only a list of multiple domains:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?domain1.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?domain2.com.*$ [NC]
RewriteRule .(gif|jpg)$ - [F]

Where the logic reads

Was this answer helpful?

Also Read