Use .htaccess to redirect non www to www

htaccess redirectIt’s is considered good practice, for both SEO and users, to have your website resolve to one URL. Technically speaking is a subdomain of Users often type www. prior to the domain in the address bar. So to keep that formality consistent with your users you can redirect the traffic on to


If your website is hosted on an apache server, this redirect from non www to www is a simple implementation. Add this to your .htaccess file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule (.*)$1 [L,R=301]

Add the above code to you .htaccess file and replace with your domain name.

I have another post on how to redirect www to non-www with .htaccess.

Want to learn more about apache? Try this resource...

Apache Cookbook: Solutions and Examples for Apache Administrators