Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this.</p> <pre><code>RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} ^https?://(www\.)?([^/]+)/.*$ [NC] RewriteCond %2#%{HTTP_HOST} !^(.+)#(www\.)?\1$ [NC] RewriteRule \.(bmp|gif|jpe?g|png|swf)$ - [F,L,NC] </code></pre> <p>Would even work when only one of the referrer or target url has a leading <code>www.</code></p> <p><em><strong>EDIT</strong> : (how does this % thing work?)</em><br /></p> <p><code>%n</code> references the <strong>n</strong>(th) bracket's matched content from the <em>last</em> matched rewrite condition.</p> <p>So, in this case</p> <ul> <li><code>%1</code> = either <code>www.</code> OR <code>""</code> blank (because it's optional; used <code>()?</code> to do that)</li> <li><code>%2</code> = <code>yourdomain.com</code> (without <code>www</code> always)</li> </ul> <p>So, now the rewrite condition actually tries to match</p> <pre><code>yourdomain.com#stealer.com OR yourdomain.com#www.stealer.com </code></pre> <p>with <code>^(.+)#(www\.)?\1$</code> which means <code>(.+)#</code> anything and everything before <code>#</code> followed by <code>www.</code> (but again optional); followed by <code>\1</code> the first bracket's matched content (within this regex; not the rewrite condition) i.e. the exact same thing before <code>#</code>.</p> <p>So, <code>stealer.com</code> would fail the regex while <code>yourdomain.com</code> would pass. But, since we've negated the rule with a <code>!</code>; <code>stealer.com</code> passes the condition and hence the hot-link stopper rule is applied.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload