Forum Moderators: phranque
Basically i want to prevent image hotlinking from my site so in .htaccess I have added.
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?66.xx. xx.xx(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp)$ - [F,NC]
This does indeed prevent hotlinking however it does not allow access or to publish through Microsoft FrontPage without me rewriting it.
If I add 'RewriteEngine off' as the last line, it allows me access but does not block hotlinking.
Welcome to WebmasterWorld!
Frontpage extensions and .htaccess do not play nicely with each other. However, there is a fix. See
[webmasterworld.com...] message #43 for more information (read back up that thread for background).
In addition, you code will need one change and could use some cleaning-up:
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://192\.168\.6\.10 [NC]
RewriteRule \.(gif¦jpe?g¦bmp)$ - [F,NC]
Change all broken pipe "¦" characters above to solid pipe characters before use. Posting on this forum modifies them.
Jim
One problem though
RewriteCond %{HTTP_REFERER} .seems to allow hotlinking, if it is removed then no hotlinking
try this image with the above line in
[<snip>...]
[edited by: jdMorgan at 11:40 pm (utc) on Nov. 18, 2005]
[edit reason] No URLs, please. See TOS. [/edit]
[added] Flush your browser cache before and during tests of new access-control code. If your browser caches an image, then it won't ask the server for the image, and your code will have no effect. [/added]
Jim