14
Apr
2011

How to redirect non-www to www

Posted in: SEO, Webmaster No Comments


I have seen lots of people asking this question. Most webmaster want to have one type of url for their website either domain.com or www.domain.com

If you want to have all urls as www.domain.com just add below code in .htaccess located in the root directory of your website.

RewriteEngine On
RewriteBase /
RewriteCond % ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

If you want to have all urls as domain.com just add below code in .htaccess located in the root directory of your website.

RewriteEngine On
RewriteBase /
RewriteCond % ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

NOTE: Change yourdomain.com in above code to your site domain name like 9zap.com

About the Author

Name: Ravi Shekhar
I love learning and sharing web stuffs.

Share this post

Twitter Facebook Google Buzz Digg StumbleUpon Delicious Technorati

Leave a Reply