The settingsettings
I have the following .htaccess.htaccess rule
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} !^de\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This works great to redirect any subdomain that is not valid (wwwwww
or dede
) to the wwwwww
subdomain.
I have seen solution, but they only depend on single domain sites.
I have multiple domains,:
http://www.example.com
http://www.example.net
http://de.example.com
which all serve their own brand of site.
Now I have the htaccess.htaccess rule that is mentioned above and it works beautifully if someone types in http://example.com
it redirects to http://www.example.com
.
The problem
If someone types in
http://test.example.com
http://test.example.com
, it redirects to
http://www.test.example.com
http://www.test.example.com
and
If if someone types in
http://test.example.net
http://test.example.net
, it redirects to http://www.test.example.net
.
http://www.test.example.net
The question
How can I make it so that it redirects http://test.example.comhttp://test.example.com
to http://www.example.comhttp://www.example.com
? And http://test.example.nethttp://test.example.net
to http://www.example.nethttp://www.example.net
.
I need an domain insensitve solution because more domains will be added in the future.