force all urls to www and force domain to non-www
- by Digital site
I was trying to force my domain to redirect without www and could success through this code:
.htaccess:
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^(.*) http://domain.com/$1 [R=301,L]
however, this code is going to redirect all www to non-www, which is not what I want. I just want to make the main domain from www.mydomain.com to mydomain.com and the rest of the urls should be forced to www.
any idea how to add or modify the code so I can achieve that through .htaccess ?
Update: Thanks to all. I found out that swf file from piecemaker was corrupted and updated it with new one. so now it is all fine and works on both www and non-www. I'm still curious how to solve this issue anyways using .htaccess. Thanks again.