UnixServerAdmin

Server Administration & Management

How to Redirect from http://domain.com to http://www.domain.com

If you want to redirect your domain from  http://domain.com  to http://www.domain.com, then add the following lines in the .htaccess file for domain for which you want to set the redirection

============================================================
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/?$ “http://www.domain.com ” [R=301,L]
============================================================

Advertisements

June 7, 2011 Posted by | Apache, htaccess | , , | 4 Comments