Thursday, June 6, 2013

Redirect from domain.com to www.domain.com using .htaccess

First step create a .htaccess file in your wwwroot folder (Windows hosting) or your public_html folder (Linux hosting), containing the following, replacing domain.com with your domain name:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Disqus Comments