Apache .htaccess Hotlink CDN / Parallel Subdomains Drupal CDN

Author:
phil
Created:
Saturday, December 03rd, 2011
Last Updated:
Friday, February 17th, 2012

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service


Extending my blog: apache .htaccess rewrite cdn / parallel subdomains a little further, I wanted to also ad some code to block hot linking from the primary domain as well as include the CDN / parallel subdomains as well.

If you don't know what "hot linking" is, it is a way to keep people, bots from hosting YOUR images, on THEIR website. When someone does this, it eats away at your bandwidth because you are basically hosting a file for someone else at that point... I see a lot of these coming from cash pages in Russia and the like... If you have unlimited bandwidth hosting it isn't that big of a deal, but keep in mind that there is always a bottleneck of some kind with your hosting bandwidth and the more people leeching pictures and files from you, the less bandwidth to go around for everyone using that service.

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://example1.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https?://(srv(1|2|3)\.)?example1.com/.*$ [NC]
RewriteRule ^.*\.(gif|jpe?g|png)$ http://example2.net/misc/images/hotlink-image.jpg [NC,R,L]

Post Comment

Comments

hi phil,
it will for sure help those who are not aware about hotlinking or subdomains.

thanks
sunil