Currently we are using the following code in .htaccess to redirect users from mydomain.com to http://www.mydomain.com … simply because we need/want the www. to always be there.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
</IfModule>
We intend to add several add-on domain to hit this same site is there a way to customize the above code such that any domain would behave the same?
UPDATE
So I managed to achieve this by using
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
It’s still not perfect because I want to avoid this happening with subdomains of the site. So if for example someone hits with hello.mydomain.com … I don’t want it to add the www.
Any help pleaese?
Thanks
Thanks
Oki found the solution in another question:
Thanks