I’m having some issues with rewrites for blocking hotlinking of images under certain conditions and I was wondering if anyone could take a look at what I’ve got so far and whether that’s the best approach:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\\.)?mysite1.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\\.)?mysite2.org/.*$ [NC]
RewriteCond %{REQUEST_URI} !^/?Special/Directory/ [NC]
RewriteRule \\.(gif|jpg|png|mp3)$ - [F,NC,L]
RewriteCond %{HTTP_REFERER} ^http://(.+\\.)?bannedsite1\\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\\.)?bannedsite2\\.com/ [NC]
RewriteRule \\.(gif|jpg|png|mp3)$ - [F,NC,L]
Alright, this is what I am trying to do:
- First, allowing direct access.
- Allowing linking from mysite 1 & 2.
- Allowing all images in Special/Directory to show up anywhere since they are included on various aggregated feeds.
- Blocking bannedsite 1 & 2 even from Special/Directory