| When our we page (s) is (are) indexed in both the form with www
and also without www in that case search engines feels that our
website is having duplicate web page (s) and our website is
penalized so it is very important to put 301 redirect for our web
pages. If we don't like to put 301 redirection for our website
then also we can fix this cannonical domain issue problem with
google web master tool but only Google will follow your instruction
some other major search engines like Yahoo, Bing will not consider
and they may index our web page in both the form with www. and
without www so it is better way that we put 301 redirection for our
domain which will resolve issue in mostly all search engines
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]
|