Force www .htaccess redirect to avoid duplicate content

edited March 2013 in Web Development
Create a file called .htaccess in the root directory of your server.

Enter this is in the file:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301]

Comments

  • You can also use this one:
    RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
    
Sign In or Register to comment.