Reputation: 367
I'm trying to create a regex for apache that will ignore certain strings, but will use anything else. Ive tried many different methods however i just can't seem to get it correct.
for example
i want it to ignore
ignore.mysite.com
but anything else i want it to use
*.mysite.com
Upvotes: 1
Views: 315
Reputation: 21999
If you want a regex that matches whatever.mysite.com
where whatever
is any possible hostname, but you want the regex not to match ignore.mysite.com
, then try this:
^(?!ignore)[a-z0-9-]+\.mysite\.com
The trick is to use negative lookahead.
Upvotes: 1
Reputation: 481
If you want this regular expressions for mod_rewrite, you can use RewriteCond with negation, just like this:
RewriteCond %{REMOTE_HOST} !^ignore.example.com$
RewriteRule ....
You can find more, of course, in documentation.
Upvotes: 0