Technology Blog

Redirect non www to www using .htaccess

0

Copy and append the code below to your .htaccess:

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

Save your .htaccess file and try to enter domain.com at your browser and it should be redirect you to www.domain.com automatically now.