Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Rewrite image for specific referrer


lucy24 - 7:45 am on Nov 5, 2012 (gmt 0)


RewriteCond %{HTTP_REFERER} ^http://(www\.)?thereferrer\.com [NC]
RewriteRule .* - [F]

You do not need (www\.)? here, unless you are personally acquained with the referring site and you know for a fact that they don't canonicalize. Otherwise it's either with or without; the wrong way would be a forged referer. Look closely at your logs and you'll find fake referers from your own site getting caught this way. Give the referring site name in its exact, full form. If it's a specific page, name it.

So how come the two parts do not work?
RewriteEngine On
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} ^http://(www\.)?thereferrer\.com [NC]
RewriteRule ^images/image\.png$ http://www.example.com/directory/images/new-image.png[L]

Even though it's mis-coded as a redirect instead of the intended rewrite note lower case it should still work. Have you tried it with a different browser? One whose cache has never seen the page in any form.

Is it serving up the originally requested image, or no image at all?

For testing purposes, set the "expires" header for new-image.png (NOT the requested image.png but the one that is actually served) to "right away". You can look up the exact terminology yourself ;) It will save you having to empty your browser cache every time you test the rule.


Thread source:: http://www.webmasterworld.com/apache/4515652.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com