Reputation: 7390
I need to write a condition in .htaccess in which all hosts starting with a word will be ignored. For instance, i want it to ignore to example.com, example.com.br, example.com.uk, example.com.au and so on.
So far the only way i know to do this is to writing one rule for each, like this :
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com\.br$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com\.uk$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com\.au$ [NC]
Is there a way to write only 1 rule for all ?
Thanks
Upvotes: 0
Views: 625
Reputation: 785146
You may write a single condition using regex:
RewriteCond %{HTTP_HOST} !^(?:www\.)?example\.com(?:\.(?:br|uk|au))?$ [NC]
Or if you may want to just use:
RewriteCond %{HTTP_HOST} !^(?:www\.)?example\.com(?:\.|$) [NC]
Upvotes: 1