My .htaccess file is in the root, and services multiples websites.
It contains a RewriteEngine block.
I'd like to prevent Apache evaluating rules if the host is not (www) www.example.com:
RewriteEngine On
RewriteBase /
#If this is not about example.com, it is probably about our other websites, exit here
RewriteRule %{HTTP_HOST} !^(www|)example.com$ - [L]
however, this leads to a 500 internal error. Probably due to the usage of {HTTP-HOST} is a RewriteRule directive.
So I'm now thinking about something like this:
RewriteCond %{HTTP_HOST} !^(www|)example.com
RewriteRule (.*) $1 [L]
But this would require an Apache rewrite and is bad for the performance.
Anyone a suggestion?