Forum Moderators: phranque

Message Too Old, No Replies

hotlinking problem

         

rovink

5:16 pm on Feb 1, 2005 (gmt 0)



I have a problem with my .htaccess to prevent hotlinking to some files. It also blocks the external sites which have permission to load the files.
Can somebody tell me what if done wrong?


RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://(www\.)?(example1¦example2)(\.nl¦\.com)/?.*$ [NC,OR]
RewriteCond %{HTTP_REFERER}!^http://example3\.nl/?.*$ [NC,OR]
RewriteCond %{HTTP_REFERER}!^$
RewriteRule .*\.(wav¦js)$ - [F]

Thanks,
Richard

[edited by: jdMorgan at 6:00 pm (utc) on Feb. 1, 2005]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

6:08 pm on Feb 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Richard,

Welcome to WebmasterWorld!

> Can somebody tell me what if done wrong?

Yes, remove the [OR] flags from your RewriteConds. The logical structure you want is:
If ((NOT(valid_referrer1 OR valid_referrer2)) AND (NOT(valid_referrer3)) AND (NOT(-blank-)) THEN forbid access.

You can also get rid of the unneccessary ".*" sub-pattern prefixes and suffixes -- they don't do anything.

Also, you should not end-anchor the allowed referrers -- If you do, then image-linking will not be possible from any subpage of those domains:


RewriteEngine On
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?(example1¦example2)\.(nl¦com) [NC]
RewriteCond %{HTTP_REFERER} !^http://example3\.nl [NC]
RewriteRule \.(wav¦js)$ - [F]

Replace all broken pipe "¦" characters with solid pipes before use.

Jim