Jump to content

no www to www


mga_ka_php

Recommended Posts

i have several websites in one cpanel account. how do i write in htaccess move the domain.com to www.domain.com for multiple domain?

 

my existing rule is

RewriteCond %{HTTP_HOST} ^mydomain.com [NC]

RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

 

but i have several domains, my htaccess file will be long if i write that for each domain.

 

any suggestions? thank you.

Link to comment
https://forums.phpfreaks.com/topic/199643-no-www-to-www/
Share on other sites

I've never really used cPanel, but I would assume that since a .htaccess file is per directory, that it would only apply to a single domain. If you wanted to work with all domains you would have to add it into the conf file. Alternatively create a .htaccess file for each domain. Either way the rule would probably be something along the lines of...

 

RewriteCond %{HTTP_HOST} !^www
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,QSA]

Link to comment
https://forums.phpfreaks.com/topic/199643-no-www-to-www/#findComment-1047919
Share on other sites

Hmm... I can't think of a single solution across multiple domains. If they are all in the same top level domain (such as .com you could perhaps use something like this...

 

RewriteCond %{HTTP_HOST} ^[^.]+\.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,QSA]

 

...but that's just a theory, haven't tested it.

Link to comment
https://forums.phpfreaks.com/topic/199643-no-www-to-www/#findComment-1049168
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.