I am looking for a generic (host-independent) mod_rewrite rule set to check for HTTP_REFERER resources. I came up with the following, which seemed intuitive, but unfortunately does not work:
RewriteCond %{HTTP_REFERER} !^https?://%{HTTP_HOST}/.* # RewriteRule .* - [F] # <- or whatever
Apparently, you cannot have a variable on either side of the comparison. So hack:
RewriteCond %{HTTP_HOST}##%{HTTP_REFERER} !^([^#]*)##https?://\1/.*
But wow, that’s ugly - and if you don’t know exactly what is going on, it is terribly confusing.
Is there a better (cleaner) way to write these rules?
tylerl
source share