PDA

View Full Version : Hotlinking prevention not working



fronaphoto
08-24-2009, 11:58 AM
I have a .htaccess file in my root folder with the following:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://fronaphoto.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://fronaphoto.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.fronaphoto.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.fronaphoto.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|cab)$ - [F,NC]

However, the images on my site are still able to be hotlinked. I am not a programmer; what am I doing wrong here?

JND
08-24-2009, 12:20 PM
I have never used this, but see if this works for you:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?fronaphoto.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|bmp|cab)$ - [NC,F,L]

fronaphoto
08-24-2009, 12:34 PM
No, I'm trying to test it on a site such as this:
http://www.htaccesstools.com/test-hotlink-protection/
but the image still shows.

JND
08-24-2009, 12:43 PM
That's odd. Using the above code and your provided tool, I received the following result:

felgall
08-24-2009, 01:11 PM
No, I'm trying to test it on a site such as this:
http://www.htaccesstools.com/test-hotlink-protection/
but the image still shows.

You probably have the referrer header turned off in your browser so that it doesn't know what site you are requesting the images from and so has to serve them. Hotlink protection only blocks the images when the referrer header is on (which it will be for most visitors to most sites).