Redirect myDomain.com to www.myDomain.com

Discussion in 'Apache' started by cre8ive, Sep 10, 2008.

  1. #1
    If the user enters from the url myDomain.com, I want redirect the url to www.myDomain.com automatically. How do I do this on Apache? I seem to remember that this can easily be done using .htaccess or adding an entry in httpd.conf, but I cannot recall exactly how.

    (By the way, if I do this, then Google will replace myDomain.com with www.myDomain.com, right? As of right now, Google lists myDomain.com, but I want www.myDomain.com to be listed. This is the website in question, FYI.)
     
    cre8ive, Sep 10, 2008 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    If you are doing that just for google results to appear with www. then you can do that through Google Webmaster Tools. Join there, and you will find that option under Tools > Set preferred domain and then check option "Display URLs as www.yourdomain.com". That's it, on the next update google should start showing your site results with www.yourdomain.com
    You can put a redirection on server side also, to redirect from http://yourdomain.com to http://www.yourdomain.com as an additional measure.
     
    pr0t0n, Sep 10, 2008 IP