301 Redirect With No WWW Using Htaccess
The first thing you will need is access to your webroot .htaccess file (located where your index page is). Some of you may not have .htaccess files or are running a single website off your server so you can do this in httpd.conf.
Redirecting With No www
The sample code below will use Apache's mod_rewrite to redirect (R=301) your domain to the same domain without the 'www.' subdomain.
<IfModule mod_rewrite.c>
RewriteEngine on
# 301 redirect to domain without 'www.'
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
</IfModule>Redirecting To www
The sample code below will use Apache's mod_rewrite to redirect (R=301) your domain to the same domain with with the 'www.' sub domain.
<IfModule mod_rewrite.c>
RewriteEngine on
# 301 redirect to domain to 'www.'
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</IfModule>301 Redirect With Drupal
For those of you with Drupal simply enter the lines below above the second 'chunk' of directives which wil be identical to your Drupal default .htaccess.
# 301 redirect to domain without 'www.'
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]More Drupal SEO
To learn more about Drupal SEO techniques follow our Drupal SEO Video Tutorial which will walk you through 5 of the most popular Drupal SEO modules.
Delicious
Digg
StumbleUpon
Reddit
Facebook