[ACCEPTED]-Allow/deny image hotlinking with .htaccess-hotlinking

Accepted answer
Score: 24
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?otherdomain\.com [NC]
RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L]

Will work, as this says.

"Refererr is not 5 nothing, and referer is not matching mydomain 4 and referer is not matching otherdomain.

If 3 it were the case that you were trying to 2 do the opposite (blacklist a set of domains 1 from hotlinking) you'd do something like

RewriteCond %{HTTP_REFERER} ^http://(www\.)?baddomain1\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?baddomain2\.com [NC]
RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L]
Score: 3

Just add another condition before the RewriteRule for each domain 4 you want to allow.

RewriteCond %{HTTP_REFERER} !friendlysite\.com [NC]  

(presumably you don't 3 care if the request is via http or https 2 or whatever, so you can leave that out to 1 make it more generic)

More Related questions