Forum Moderators: phranque
I make a portal (www.mysite.com) about greek islands and in my htaccess file i have the following code to prevent hotlinking
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite.com/.*$ [NC]
RewriteRule \.(gif¦jpg¦js¦png)$ - [F]
Now the owner of the portal wants to make one site per greek island (www.islnad-name.com) and we want to get banners/images from the first site (www.mysite.com).
In total there will be 45 sites (one basic and 44 specific ones). Total images in basic site are more than 9000 (about 850MB of jpg)
Is there a way to allow hotlinking for my sites and block all others so as to avoid uploading more copies of the images again and again and again?
you can add another line for each of the 'islands' that you want to accept hotlinking from eg
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite.com [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?my-other-site.com [NC]
RewriteRule \.(gif¦jpg¦js¦png)$ - [F]
I guess there are quite a few greek islands so this may get quite long over time as you add them?
You could help your server out with a couple of processing effort savers:
- you don't need the trailing .*$ on each of those - it uses processing effort as it checks for a match to .*, which matches everything anyway.
- if you are enforcing www or non-www then you can also lose the pattern match at the start and save your server a little more effort. eg just have [mysite.com...] or [mysite.com...]
hth
Andy