Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Redirecting from www to non-www domain
I would like to redirect visitors coming from http://www.domain.com to http://domain.com
Here is the code I plan on using:
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^www\.DOMAIN.com [NC]
RewriteRule ^(.*) http://DOMAIN.com/$1 [L,R=301]
Where is the best place to place this code in the root .htaccess file?
- Line 1?
- After
#php_value register_globals 0
? - Somewhere else?
Thanks for your help.
Sam Brown
sambrown.me | welovetxp.com
Offline
#2 2007-11-30 14:45:37
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Redirecting from www to non-www domain
Before the txp rewrite rules.
Offline
#3 2007-11-30 16:22:49
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: Redirecting from www to non-www domain
Sam
should your posted RewriteCond
be…
RewriteCond %{HTTP_HOST} ^www\.DOMAIN\.com [NC]
(note the extra ‘\’ before the ‘.com’ part) instead of…
RewriteCond %{HTTP_HOST} ^www\.DOMAIN.com [NC]
I don’t know for sure as I’m a newbie at mod_rewrite regular expressions.
— Steve
Offline
Re: Redirecting from www to non-www domain
Quite probably yes, I am using the following and it is on the first line of my .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Sam Brown
sambrown.me | welovetxp.com
Offline
Re: Redirecting from www to non-www domain
Sam’s proper RewriteRule is also to be found at no-www.org, below the fold.
Offline
#6 2007-12-01 00:34:36
- masa
- Member
- From: Asturias, Spain
- Registered: 2005-11-25
- Posts: 1,091
Re: Redirecting from www to non-www domain
While I agree that any website should function no matter whether you use the prefix or not, I’ve never quite understood all the rants against www in the first place.
It certainly serves a purpose in printed material, where people are more likely to spot a website address that’s prefixed with www, much like the @ identifies an email address.
Offline
Re: Redirecting from www to non-www domain
masa, maybe because:
- www is a subdomain, as a email.domain.com is subdomain for a email-server.
- Searchengines find domain.com and www.domain.com as double content.
And secondly when redirecting:
- You can still use www.domain.com-address but it redirects to domain.com – so that point ain’t changed.
Cheers!
Last edited by Gocom (2007-12-04 09:30:24)
Offline