how to force www

Topics: Developer Forum, User Forum
Oct 26, 2007 at 8:05 PM
Hi all,

I am having problems forcing a redirect to http://www.mydomain.com when the client shows up with http://mydomain.com. The same goes for https traffic. Here is what I am using. Any ideas?


  1. Force the www host
RewriteCond %{HTTPS}
RewriteCond %{HTTP_HOST} ^mydomain\.com I
RewriteRule ^/(.*) https://www.mydomain.com/$1 R,I


  1. Force the www host
RewriteCond %{HTTP_HOST} ^mydomain\.com I
RewriteRule ^/(.*) http://www.mydomain.com/$1 R,I

Thanks,

Mike
Oct 31, 2007 at 1:57 PM
I'm using it like this

RewriteCond %{HTTP_HOST} ^(?!https?://)mydomain\.com I
RewriteRule ^/(.*) http://www.mydomain.com/$1 I,R=301

Hope this helps,
RvdH
Oct 31, 2007 at 6:13 PM
Hooray! Thanks RvdJ.