force all urls to www and force domain to non-www
Posted
by
Digital site
on Server Fault
See other posts from Server Fault
or by Digital site
Published on 2012-10-26T20:14:19Z
Indexed on
2012/10/26
23:04 UTC
Read the original article
Hit count: 347
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.
© Server Fault or respective owner