View Full Version : htaccess hotlinking

08-12-2007, 09:08 AM
I have set up in my .htaccess to block hotlinking to images except from specific domains, and except to a specific subfolder on my website. However this subfolder is also used as a subdomain, and my code isn't working for the subdomain (while it does work on the subfolder)

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/p
RewriteRule ^.*$ - [L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !example\.com [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /l?/$1 [R,NC,L]So basically I'm blocking hotlinking from anywhere but my domain, except to the subfolder "/p" - anywhere can hotlink to that subfolder. But if a site hotlinks to the subdomain "p" (eg p.example.com) the hotlink is broken.

And ideas on how to allow hotlinks to that subdomain?


10-12-2007, 01:02 PM