...

View Full Version : htaccess hotlinking problem



remo
09-15-2006, 08:38 AM
Can anyone help, I have a site with a lot of WMV, MPEG, DCR and SWF files which I am trying to stop from being hotlinked.

I have a Linux based shared hosting account on Godaddy

This is .htacess file I have placed in my root but I have tried hotlinking it from another domain and works every time

This is the code I am using


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.co.uk [NC]
RewriteRule \.(jpg|jpeg|png|gif|wmv|avi|gif|swf|dcr|mpeg|mpg)$ - [NC,F,L]

Anyone have any ideas where I am going wrong or why its not working
Really appreciate any advice
Remo

_Aerospace_Eng_
09-15-2006, 05:14 PM
This is what I use

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://yoursite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://yoursite.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]
And it seems to work quite well.

remo
09-15-2006, 05:47 PM
will give it a try and wait for the server refresh

Thanks for replying!

remo
09-16-2006, 07:33 AM
Have got it to work for images but does not work for wmv files and the only part of the code i edited was for my domain name

Any suggestions?

_Aerospace_Eng_
09-16-2006, 04:33 PM
Hmm I've tried it with other extensions as well and it seems to work. It should only happen when a direct call to the file is made, something like
http://www.yoursite.com/somefile.wmv this should return a 403 Forbidden error. Not sure why its not working for you, maybe you've messed something up? Can you post the htaccess you are using now?

remo
09-16-2006, 06:02 PM
Just used what you provided


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]

Were moving to a new site design next week and also need to be sure we can stop hotlinking from swf, avi, dcr, mpeg etc... as were moving to a new design we have to amend every page so was thinking might just be best to encypt the code for all the players and game files and in the process change the names of the worst affected files, painful to do but will probably offer best protection.

Some of the files which people enjoy the most hotlinking are 20MBs + s so as can you imagine lots of bandwidth pressure

_Aerospace_Eng_
09-16-2006, 11:46 PM
You didn't look carefully. You need to use the www. url as well

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum