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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.