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 »

  1. Thanks a lot for taking a few minutes to line all this out for people like us. This particular write-up ended up being quite useful in my opinion.

    Comment by Floyd Karapetyan | June 15, 2011 | Reply

  2. I’d personally like to read all that you know regarding this subject matter. You have only scraped the top of your knowledge on this and that’s obvious from the way you blog. Have you considered devoting a complete web page to ensure that other people won’t miss what you have to say?

    Comment by clean water | June 15, 2011 | Reply

  3. Your information truly fills a need. I’ve been wanting to locate this specific blog and you really came through. Can you imagine that what you have written pretty much specifically replicates my own experience.

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

  4. I did that, and my domain http://site.com now redirects to http://www.site.com

    My question is, I installed wordpress /blog

    but when you look it up it shows as http://site.com/blog
    what I want is http://www.site.com/blog

    Is there a way around that?

    Comment by Gerry | August 5, 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: