Forum Moderators: phranque

Message Too Old, No Replies

www.domain.com -> domain.com redirect

         

Dolemite

10:12 am on Apr 15, 2003 (gmt 0)

10+ Year Member



For a new site I'm developing, not having the 'www' in the URL is a branding concept I'd like to maintain. Obviously, for all the cases where I can control links to this site, I'll be linking to domain.com, but I want to have a 301 set up ahead of time to maintain PR for the cases where other people link to www.domain.com.

I'm still developing the site so I haven't tested this, but I think this should work:

RewriteCond %{HTTP_HOST} ^www.domain\.com
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

Does that look OK? Also, is there anything I need to do in setting up DNS to make sure I have the right settings for domain.com? I'm using WHM/cPanel...I just got a reseller account and this is the first time I've had that much control.

johannes

6:38 am on Apr 16, 2003 (gmt 0)

10+ Year Member



I have this config myself:

RewriteCond %{HTTP_HOST} ^www.*$
RewriteRule ^.*$ [domain.com$0...] [R=301]

The differences:
I use $0 at the end of Rewriterule, but perhaps $1 will work the same.

No slash before $0.

The ",L" isn't necessarry if you haven't got more rewrites after that.