Server Administration & Management

How to Redirect non-www to www domain using .htaccess

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]

March 13, 2011 - Posted by | Apache, htaccess | , ,


  1. I can tell that your particular knowing of this subject is strong and comprehensive. What a delicacy to locate somebody writing that not simply offers knowledge but also the opportunity to connect through easy to picture and remember info-bytes. Write a lot more!

    Comment by filtered water | June 15, 2011 | Reply

  2. Your skill to communicate these types of information and facts is precisely what every one of us have to have. By simply revealing your understanding you support people via discussing your own personal experience. And I’ll inform you now your article served me.

    Comment by blog about water | June 16, 2011 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: