Page 1 of 1
preventing hotlinking
Posted: Mon Jul 07, 2008 9:35 am
by jan_hut
to prevent people from hotlinking to images use this code in you .htaccess file:
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.tld/ [NC]
RewriteRule \.(gif|jpg)$ - [F]
if you want to allow more referrers you can add the secondline with a different referrer
Re: preventing hotlinking
Posted: Mon Jul 07, 2008 12:13 pm
by cyberman
Well done - thanx.
Re: preventing hotlinking
Posted: Mon Jul 07, 2008 6:13 pm
by JeremyBASS
Hey just try this out... Got some odd results... the jpg and gif images were not showing up in the site... admin and front end... any ideas on this...
the cms lives in a folder on the root so to get to the site... it's sitename.org/folder/index.php... not sure if that is the issue...
#Stop Hotlinking to Items...
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sitename\.org/ [NC]
RewriteRule \.(gif|jpg)$ - [F]
good idea here...

Re: preventing hotlinking
Posted: Sun Jul 13, 2008 9:38 am
by jan_hut
Jeremy, are you using a subdomain to point to that folder? something like folder.yoursite.org

in that case you'd just add it to the could, something like this:
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.tld/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(folder\.)?yoursite\.org/ [NC]
RewriteRule \.(gif|jpg)$ - [F]
Re: preventing hotlinking
Posted: Sun Jul 13, 2008 9:49 am
by JeremyBASS
no but now that I think abut it ... I was in https... that I think is the problem... I'll try again later