I am searching for a normal (host-independent) group of mod_rewrite rules for doing HTTP_REFERER looking into assets. I emerged using the following which appeared intuitive, but sadly does not work:

RewriteCond %{HTTP_REFERER} !^https?://%{HTTP_HOST}/.*
# RewriteRule .* - [F]  # <- or whatever

Apparently you cannot possess a variable on sides from the comparison. So, a hack:

RewriteCond %{HTTP_HOST}##%{HTTP_REFERER} !^([^#]*)##https?://\1/.*

But wow, that's ugly -- and when you do not know exactly what's happening, it's terribly confusing.

It is possible to better (cleaner) method to write these rules?