Forum Moderators: phranque
Options +FollowSymlinks
#
RewriteEngine On
#
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/images/hotlink\.gif$
RewriteRule \.(gif|jpg|png)$ http://www.example.com/images/hotlink.gif [R=302,NC]
[edited by: jdMorgan at 5:03 pm (utc) on Jun 27, 2010]
RewriteCond %{HTTP_REFERER} !^http://www.\.example\.com [NC] RewriteRule /* http://example.com [R,L]
Options +FollowSymlinks
#
RewriteEngine On
#
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/images/hotlink\.gif$
RewriteRule \.(gif|jpg|png)$ /images/hotlink.gif [L]
RewriteCond %{HTTP_HOST} !^http://www.mysite.com [NC]
RewriteRule /* http://www.mysite.com [R,L] RewriteCond %{REQUEST_URI} !^/images/hotlink\.gif$ Options +FollowSymlinks
#
RewriteEngine On
#
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/images/hotlink\.gif$
RewriteRule \.(gif|jpg|png)$ /images/hotlink.gif [L] RewriteCond %{HTTP_REFERER} !^http://www\.example\.com [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC] RewriteEngine on
RewriteCond %{HTTP_HOST} !^.*example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301] The modification that I last made to the code above was to change the original code which invoked an e[x?]ternal 302 URL-to-URL redirect to so that it became an internal URL-to-filepath rewrite; Image requests with non-blank incorrect referer headers are now internally rewritten to access a different *file* than normal, rather than sending a redirect response to the browser to tell it to GET that alternate file using a new HTTP request. Therefore, the new code does not inform the browser that an alternate image is being served, and so the address bar does not change.
RewriteCond %{...}, distinguish the two requests?
{HTTP_REFERER}, distinguish between address bar and internal page requests, AND also between AOL-type requests (which, it seems to me, are the same as any other internal page request except for the referrer issue)?