PDA

View Full Version : What is hotlinking, examples for .htaccess



Fli
05-27-2013, 11:15 AM
What is hotlinking in webmaster terminology?


Does it mean that my website disallow some external site to load my websites content during thirdparty site loading?


Is it good idea to turn off hotlinking php, html, js, jpg, zip files?


Example of turning off hotlinking
Enter this code into ".htaccess" file in your website root directory:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)mysite.com/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|bmp|zip|rar|mp3|flv|swf|xml|php|pn g|css|pdf)$ - [F]

(PS: make sure, there are no spaces in "...bmp|zip|rar|mp3|flv|swf|xml|..." part. this forum makes spaces in long words..)

Example of serving alternative image on hotlinking

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)mysite.com/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|bmp|zip|rar|mp3|flv|swf|xml|php|pn g|css|pdf)$ http://www.mysite.com/hotlinking_forbidden.gif [R,L]

(PS: make sure, there are no spaces in "...bmp|zip|rar|mp3|flv|swf|xml|..." part. this forum makes spaces in long words..)