Home > Apache > Redirect non www traffic to use the www before the domain name – htaccess solution
Bookmark and Share

Redirect non www traffic to use the www before the domain name – htaccess solution

Posted on March 24, 2014 | Filed in Apache

Add the following code to your .htaccess file in your website root folder to redirect all non “www” traffic to use the “www”.

So people typing in http://yourdomain.com will be redirected to http://www.yourdomain.com automatically.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Leave a Reply