Skip to main content
Tweeted twitter.com/#!/StackWebmasters/status/429200469563801600
Formatting + retagging
Source Link
Zistoloen
  • 10k
  • 6
  • 36
  • 59

redirect Redirect with HTTP_HOST redirects to sub sub domainsubdomain

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.

redirect with HTTP_HOST redirects to sub sub domain

The setting

I have the following .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(www or de) to the www 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 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

it redirects to

http://www.test.example.com

and

If someone types in

http://test.example.net

it redirects to

http://www.test.example.net

The question

How can I make it so that it redirects http://test.example.com to http://www.example.com? And http://test.example.net to http://www.example.net

I need an domain insensitve solution because more domains will be added in the future.

Redirect with HTTP_HOST redirects to sub subdomain

The settings

I have the following .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  (www or de) to the www 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 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, it redirects to http://www.test.example.com and if someone types in http://test.example.net, it redirects to http://www.test.example.net.

The question

How can I make it so that it redirects http://test.example.com to http://www.example.com? And http://test.example.net to http://www.example.net.

I need an domain insensitve solution because more domains will be added in the future.

Source Link
Tschallacka
  • 219
  • 3
  • 10

redirect with HTTP_HOST redirects to sub sub domain

The setting

I have the following .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(www or de) to the www 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 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

it redirects to

http://www.test.example.com

and

If someone types in

http://test.example.net

it redirects to

http://www.test.example.net

The question

How can I make it so that it redirects http://test.example.com to http://www.example.com? And http://test.example.net to http://www.example.net

I need an domain insensitve solution because more domains will be added in the future.