Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_REFERER} x\.com [NC]
RewriteRule .* - [F] RewriteCond %{HTTP_REFERER} http://x\.com [NC] RewriteCond %{HTTP_REFERER} ^http://x\.com [NC]
That's not spelled out anywhere, is it?
RewriteCond %{HTTP_REFERER} \bx\.com(/|$) [NC] example.com/newx.computers/morestuff.html All the examples out there say you have to escape the dot.
A period matches any character, so to match a literal period, it must be escaped with a backslash.
.... I missed a caret.
...a bag of apples doesn't "match" a bag of apples and bananas. It just matches a bag of apples.
...a bag of apples doesn't "match" a bag of apples and bananas. It just matches a bag of apples.
Although a bag of "fruit" does match a bag of apples and bananas, and a bag of apples.
The important thing to walk away with is that this has nothing to do with mod_rewrite and everything to do with Regular Expressions. A lot of other Apache mods use RegExes too, so once you've learned them you can apply the knowledge elsewhere.
If you ever see a RewriteRule containing \/ (escaped slashes)-- or, worse, escaped everything, or escaped anything at all in the target-- stop reading, because your source doesn't really understand what they're doing.
RewriteCond %{HTTP_REFERER} \bx\.com(/|$) [NC] If you ever see a RewriteRule containing \/ (escaped slashes)-- or, worse, escaped everything, or escaped anything at all in the target-- stop reading, because your source doesn't really understand what they're doing.
Uh, you lost me there, because the example you gave above ...
RewriteCond %{HTTP_REFERER} \bx\.com(/|$) [NC]
... had the dot escaped.