Variable Visions

Articles Apache Use-the-HTTP-REFERER-rewrite-condition-in-htaccess-to-block-sites-from-stealing-your-images-and-bandwidth


tutorials - Apache and Web-Development.

Use the HTTP_REFERER rewrite condition in .htaccess to block sites from stealing your images and bandwidth

Published Thu. Jan. 24, 2013


Today I noticed that after searching my domain name, a site has stolen some of my portfolio images. Hotlinkers! I gave them no permission and I’d hate to have a former publication or client complain. I asked them to remove my images they stole since they are violating creative commons by not giving me credit. Someone responded to my email and said they would remove, but I decided to write some code in my .htaccess file to block any site that tries to steal my images and bandwidth. You add your site ad the referer and any other sites that are allowed to link to your images.


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?variablevisions\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
THIS LEAVES A BLANK SPACE
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
OR LINK TO A “DON’STEAL MY IMAGES” IMAGE
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [L]

 

* You can also add MULTIPLE referers to allow access to images from other trusted sites
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?variablevisions\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?interstateproducts\.com/ [NC]

 


If you don't want to write your own Rewrite Conditions in your .htaccess file, you can use cPanel's "HotLink Protections" to write the code to the .htaccess file for you.


 REFERENCE:

http://altlab.com/htaccess_tutorial.html

 

 


Tag(s): HTTP_REFERER, Apache, hotlinking images, Hotlink protection



RECENT ARTICLES:

PUBLISHED ON 06.1.23arrowBuilding a JavaScript Metronome using Open AI Chat GPT

PUBLISHED ON 05.15.23arrowHow Do I Remove Footage Gaps in Adobe Premiere

TAGS

CATEGORIES