I have two domains and one valid subdomain. How can i achieve this?
ex-ample.com » example.com
www.example.com » example.com
en.ex-ample.com » en.example.com
en.example.com » en.example.com
I'm using the following .htaccess rule currently:
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Tried many but the best i can get is a redirect loop. Can you help me?
If I have correctly understood your request, I think a typical named virtual host configuration will get you what you want. I'm not entirely sure what you mean by "save virtualhost"; if this solution isn't helpful perhaps you can elaborate on your request.
In any case, I was envisioning something like this:
Now requests for any of...
...will go to the example.com VirtualHost, and requests for...
...will go to the en.example.com VirtualHost.
If all you're doing is looking for a rewrite rule, try this:
Assuming you have one virtualhost for all appropriate domains.