Forum Moderators: phranque
so from: ^mYdoMAin.com$ #Ignore case here
to: http://www.MyDomain.com/$1 #rewrite the domain part this way
But I can't seem to get it to work this way:
RewriteCond %{HTTP_HOST} ^mYdoMAin.com$ [nc]
RewriteRule ^(.*)$ http://www.MyDomain.com/$1 [r=301,C]
thanks in advance for your help!
[edited by: bill at 1:58 am (utc) on Dec. 2, 2009]
[edit reason] unlink example [/edit]
The problem with your example above I think is that it'll cause an infinite loop. You're matching mydomain.com with no case, so MyDomain.com matches. You need to match NOT www.MyDomain.com or NOT MyDomain.com.
I think this will work (untested)
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?MyDomain\.com$
RewriteRule (.*) http://www.MyDomain.com/$1 [R=301,L]
[edited by: bill at 12:54 am (utc) on Dec. 2, 2009]
[edit reason] unlinked example [/edit]
! # NOT
^ # match beginning
(www\.)? # with or without www.
MyDomain\.com # match the exact casing MyDomain.com
$ # match end
Unfortunately I can't test right now but maybe you can debug using this as a reference:
[addedbytes.com...]
In a world where the engines have enough trouble with canonical www vs non-www domains why complicate things more?
[edited by: bill at 12:56 am (utc) on Dec. 2, 2009]
[edit reason] unlink example [/edit]