preventing hotlinking

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
jan_hut
Forum Members
Forum Members
Posts: 60
Joined: Sat Jul 01, 2006 1:48 pm

preventing hotlinking

Post by jan_hut »

Image

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
cyberman

Re: preventing hotlinking

Post by cyberman »

Well done - thanx.
JeremyBASS

Re: preventing hotlinking

Post 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... :)
jan_hut
Forum Members
Forum Members
Posts: 60
Joined: Sat Jul 01, 2006 1:48 pm

Re: preventing hotlinking

Post 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]
JeremyBASS

Re: preventing hotlinking

Post 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
Post Reply

Return to “Tips and Tricks”