Jun 30 2008
htaccess 301 Redirect, www to non-www
A 301 redirect will pass pagerank through from the old url to the new url you specify. Depending on how many links are linking to your domain.com and www.domain.com, it may be wise to 301 redirect one form of your domain to the other to make sure your getting all external links pushing juice into your site.
My personal preference is to 301 redirect my www to a non-www url. I had some bad experiences with doing it the other way with a Joomla powered site of mine. The site just did’nt function as well on the registration side. I figured it was built to work best with no www. Even though I haven’t seen much of a difference with my rank after doing this, it’s been announced in many forums online that this will push the PR of the www to the non-www resulting in higher rankings. I guess results will vary depending on how many links are actually coming into the specific url you redirect.
In general its probably best to redirect the one with the least amount of backlinks to the one with the most. Below provided both htaccess codes. Always be careful when working with the htaccess file. I’ve heard of people causing damage to their site by messing with this file too much.
HTACCESS:
www to non-www
Save the following into a htaccess.txt file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^YOURsite\.com$
RewriteRule (.*) http://YOURsite.com/$1 [R=301,L]
- Upload it to your root folder
- Rename from htaccess.txt to .htaccess
- Thats it! Pretty Simple.
HTACCESS:
non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^YOURsite\.com
RewriteRule (.*) http://www.YOURsite.com/$1 [R=301,L]






The code you were showing produced some errors, below is the best way to do it with SEO in mind.
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/1 [L,R=301]
I just checked an older site I remember using a couple forms of 301 redirect on.
a non-www to a www
and
redirecting the http://www.site.org/index.php to http://www.site.org.
This code is shown below…Between this one, the comment above and the post itself, you should be able to come up with a 301 solution. Thanks for your input!
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.site\.org [NC]
RewriteRule ^(.*)$ http://www.site.org/1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.site.org/ [R=301,L]