Developer Tip: Automatically add www to your domain with htaccess

After you’ve spent all those long hours developing your new website it would be remiss if you diluted your searchability by not redirecting traffic to a static domain. Without appending www to the front of your domain Google will index your site twice, etc: www.yourdomain.com and yourdomain.com. You can prevent this and make sure search engine spiders index your domain properly by adding a snippet like this to your .htaccess file.

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

This is a pretty basic tip but a useful one none-the-less.

0 Comments

Past Articles