mga_ka_php Posted April 25, 2010 Share Posted April 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199643-no-www-to-www/ Share on other sites More sharing options...
cags Posted April 25, 2010 Share Posted April 25, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/199643-no-www-to-www/#findComment-1047919 Share on other sites More sharing options...
mga_ka_php Posted April 27, 2010 Author Share Posted April 27, 2010 cags, great thanks! it's working! all the domains are parked domains, so all the sites are identical. that's what i'm looking for. thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/199643-no-www-to-www/#findComment-1049040 Share on other sites More sharing options...
mga_ka_php Posted April 27, 2010 Author Share Posted April 27, 2010 but it's not working with subdomains. it moves from sub.domain.com to www.sub.domain.com. how can we revise this? Quote Link to comment https://forums.phpfreaks.com/topic/199643-no-www-to-www/#findComment-1049047 Share on other sites More sharing options...
cags Posted April 27, 2010 Share Posted April 27, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199643-no-www-to-www/#findComment-1049168 Share on other sites More sharing options...
mga_ka_php Posted April 29, 2010 Author Share Posted April 29, 2010 it's not working. when i use the code the site goes into internal server error Quote Link to comment https://forums.phpfreaks.com/topic/199643-no-www-to-www/#findComment-1050322 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.