How do I redirect all links for www.domain.com to domain.com ?
Description of the problem:
Your website can be accessed with www.domain.com and domain.com. Since Google penalizes this due to duplicated content reasons, you have to stick your domain to either www.domain.com or domain.com.
But – since some links are outside of your website scope and the search engines already have indexed your website under both addresses, you can’t change that easily.
Solution:
Do a 301 redirect for all http requests that are going to the wrong url.
Example 1 – Redirect domain.com to www.domain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
Example 2 – Redirect www.domain.com to domain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
More From ashesh
- Nepali calendar for iPhone | Nepali Calendar | Nepali Unicode | Ashesh
- Windows 7 Themes For Free Download From Microsoft | Nepali Calendar | Nepali Unicode | Ashesh
- How can i do auto redirect using php? | Nepali Calendar | Nepali Unicode | Ashesh

