Non-www and www version there are two url format for your site. You need to fix it to prevent from duplicate content.To redirect all of your
yourdomain.com or yourdomain.com/sub-folder visitors to www.yourdomain.com or www.yourdomain.com/sub-folder, you should need to add following code at the beginning of your .htacess file in your public_html folder.For yourdomain.com to www.yourdomain.com
RewriteEngine OnChange
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
yourdomain.com with your website name. After add it, when someone accesses to http://yourdomain.com he/she will be redirected to http://www.yourdomain.com.For yourdomain.com/sub-folder to www.yourdomain.com/subfolderRewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} ^/sub-folder/
RewriteRule ^(.*)$ http://www.yourdomain.com/sub-folder/$1 [R=301,L]
Change yourdomain.com with your website name and also sub-folder text with your existing sub-folder name. After add it, when someone accesses to http://yourdomain.com/sub-folder he/she will be redirected to http://www.yourdomain.com/sub-folderThat's it and it's safe method.
Advanced Tips: You can use it for your WordPress or any kind of site.

Comments
Post a Comment