Forum Moderators: phranque
I`m using this to prevent hotlinking but it isn`t working with referers that contain a dash "-"
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.tld/.*$ [NC]
RewriteRule .*\.(jpe?g¦gif¦png¦js¦css¦exe¦msu¦cab¦zip¦7z¦rar)$ - [F,L] Is it possible to check for referers containing a dash and block them also?
Thanks for your help
John
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteRule .* - [F]
To use for refers, simply change the portion of first line to
{HTTP_REFERER}
Please keep in mind that as a general rule, blocking refers in such a manner is a BAD practive and will deny many innocents.
Also, the way this rule is constructed, it says, "block media file requests unless the referrer is non-blank and is NOT a specific domain" (almost always your own domain).
So, what blocking function do you want to add? -- "It doesn't work" tells us nothing about your goal or your expectations.
Just as a performance tweak, I'd suggest the following minor changes.
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^(www\.)?domain\.tld/ [NC]
RewriteRule \.(jpe?g¦gif¦png¦js¦css¦exe¦msu¦cab¦zip¦7z¦rar)$ - [F]
Jim