Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://(.+\.)?example\.com/ [NC]
RewriteRule .*\.(jpg夸peg夙if如ng在mp)$ /images/stolen.png [R,NC,L]
This seems to be working now, and if i open my own site from www.example.com, the site shows the images, BUT if i prefix 'http://', i.e. if i type http://www.example.com, then my own domain is unable to show the images... please help me correct my rules
<snip>
Thanks.
[edited by: jdMorgan at 3:23 pm (utc) on May 27, 2006]
[edit reason] No URLs, please. See Terms of Service. [/edit]
If you type in a URL, there will be no HTTP_REFERER, so your rule will redirect rhe image request.
It is generally necessary to *allow* blank referrers, unless you want your site to appear to be broken when a user comes from behind a corporate or ISP caching proxy:
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com [NC]
RewriteCond %{REQUEST_URI} !^/images/stolen\.png
RewriteRule \.(jpe?g夙if如ng在mp)$ http://www.example.com/images/stolen.png [R=302,NC,L]
Jim
I was not hitting a redirect loop becuase I had placed the stolen.jpg in a folder, other then the one having the htaccess. I tried putting in the blank referral rule, but that didnt help.
But, on some other research, i added the following line of rule:
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com [NC]
So, now my full ruleset reads:
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/ [NC]
RewriteCond %{REQUEST_URI} !^/images/stolen\.png
RewriteRule .*\.(jpg夸peg夙if如ng在mp)$ /images/stolen\.png [R=302,NC,L]
seems to be working for me now, though I don't understand why :(
[edited by: jdMorgan at 4:28 pm (utc) on May 27, 2006]
[edit reason] No uRLS, please. See Terms of Service. [/edit]