Everybody know that search engine like Google hates duplicate content. You may think you write your own content and published no where else. Thus, you have no duplicate content at all. Unfortunately, http://yoursite.com and http://www.yoursite.com are not same website in search engines' eyes. That's also known as canonical problems among webmasters. Even though you don't need to worry too much for insite duplicate content, It's better if you have no duplicate content at all. So what you should do is that permanently redirect (301 Redirect) non www url to www url or do vice versa. In that way, the visitor is automatically taken to the canonical url even if they typed the wrong url or clicked the wrong link.


Apache : Redirect Using .htaccess


Redirecting non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.*$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Redirecting www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

IIS : Redirect Using web.config


Redirecting non-www to www

   
        
          
          
            
          
          
        
   

Redirecting www to non-www

   
      
         
         
            
         
         
      
   



author's photo

Author : Blue Cloud

Just a normal software developer who love to write code. Developing professional software since 1999. After working in the software industry for many years, I've started my own website to share knowledges and experiences.

COMMENTS
blog comments powered by Disqus