Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.net(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp¦html¦php¦phtml¦php3¦htm)$ http://example.net/error.html [R,NC] It goes to error.html, which is also protected by htaccess, then goes to error.html again, and again...
Any solution would be helpful.
[edited by: jatar_k at 6:42 pm (utc) on Mar. 10, 2007]
[edit reason] examplified [/edit]
RewriteEngine on
#
RewriteCond %{REQUEST_URI} !^error\.html$
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.net [NC]
RewriteRule \.(gif¦jpe?g¦bmp¦html?¦php¦phtml¦php3)$ http://example.net/error.html [R=302,NC]
The second new RewriteCond allows requests with a blank referrer header, and is recommended. Although it opens a "hole" in the hotlink protection, it will prevent you from having massive problems with blocking users sitting behind corporate or ISP proxies, e.g. EarthLink and AOL. These requests will not have a referrer, and the visitors will see your site as broken and therefore low-quality/untrustable.
Replace all broken pipe "¦" characters in the code above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim