Forum Moderators: phranque

Message Too Old, No Replies

hotlink protected folder?

         

imosh

1:38 pm on Feb 21, 2011 (gmt 0)

10+ Year Member



i technically don't mind hotlinking as 99% of our images are watermarked with our dot com. for the 1% that are not watermarked i want to prevent them from being hotlinked.

i barely know what i'm doing when it comes to certain website stuff- php,css,htaccess,etc.

is there a semi-simple way to block a single folder from hotlinking?

jdMorgan

6:02 pm on Mar 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Create a .htaccess file in the folder to be protected, and put this rule in it:

RewriteEngine on
#
RewriteCond %{HTTP_REFERER} !^(https?://www\.mysite\.com(/.*)?)?$
RewriteRule . - [F]

The "www.mysite.com" referred-to in the RewriteCond pattern must exactly match the single canonical hostname of your site. If you do not have a hostname canonicalization rule in place, then you must address that problem first (in your main .htaccess file).

This rule allows access with blank referrers as required to avoid making users of all corporate and ISP caching proxies see your site as broken.

Jim