Need help to redirect .xyz.com to www.xyz.com(auto)

Discussion in 'Domain Names' started by yogi31286, Dec 2, 2009.

  1. #1
    Hello DPs,

    I have just buy a new domain and i need little help for that.

    whenever im trying to go to my domain name by typing it in address bar like
    "xyz.com" then after full page load it looks same... like "xyz.com"

    i need help for it to redirect like this
    whenever i or someone else type in address like
    "xyz.com" then it should automatically assign the www.xyz.com after full page load..

    how can i do that?
    do i need to make changes to DNS?
    expert please reply...

    Regards,
    YOGI.
     
    yogi31286, Dec 2, 2009 IP
  2. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Put this in your .htaccess:

    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^domain.com [nc]
    rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

    Replace domain.com and www.domain.com, you must have mod-rewrite enabled.

    Voila! :)
     
    Dondon2d, Dec 2, 2009 IP
  3. mreb1010

    mreb1010 Peon

    Messages:
    684
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Who are you buying the domain names from? I purchase through godaddy and they are really easy to set up forwarding/redirecting and masking
    If you contact the company that you are purchasing from, they should be able to advise you on that
    If not, you should probably purchase your domain names from another company. Again, I use godaddy and really like them I don't really know of any other companies because I have only used them
     
    mreb1010, Dec 2, 2009 IP
  4. yogi31286

    yogi31286 Active Member

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Thanks for this help...

    @mreb1010

    I had too purchase it from Godaddy..
    can u tell me which steps i have to use to do that?
     
    yogi31286, Dec 2, 2009 IP
  5. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Don't listen to him, I think he misunderstood the question or I think he's referring to other redirections.

    Rep if I helped you :D
     
    Dondon2d, Dec 2, 2009 IP
  6. yogi31286

    yogi31286 Active Member

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    i will do it my friend... but let me first try it...
    if it works than i sure rep u...
     
    yogi31286, Dec 2, 2009 IP
  7. peterzeller

    peterzeller Peon

    Messages:
    215
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah the .htaccess trick is exactly what you want, that way Google will apply power on one page only, instead of splitting it between http://doma.. and http://www.doma...
     
    peterzeller, Dec 2, 2009 IP
  8. yogi31286

    yogi31286 Active Member

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #8
    yes... thats y i want to use it...
     
    yogi31286, Dec 2, 2009 IP
  9. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Sure buddy.
     
    Dondon2d, Dec 2, 2009 IP
  10. peterzeller

    peterzeller Peon

    Messages:
    215
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    By the way, I may be wrong but I think the third line had a little typo. Try this if it don't work:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
     
    peterzeller, Dec 2, 2009 IP
  11. yogi31286

    yogi31286 Active Member

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #11
    hhmm ok..
    i will check and reply u back..
     
    yogi31286, Dec 2, 2009 IP
  12. iama_gamer

    iama_gamer Active Member

    Messages:
    404
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #12
    are you using cpanel as the control? in which case u can easily do it from cpanel. Its the same as changing .htaccess only it does it for you!

    Go do rewrites put the domain name and say wildcard and make the redirect url to have the www
     
    iama_gamer, Dec 2, 2009 IP
  13. anakrantau

    anakrantau Member

    Messages:
    195
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #13
    I use this trick on every site of mine except wordpress blog because wordpress has a similar system built-in.

    here are the code for .htaccess :

     
    anakrantau, Dec 2, 2009 IP
  14. yogi31286

    yogi31286 Active Member

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #14
    is it working properly?

    @anakrantau
     
    yogi31286, Dec 2, 2009 IP
  15. iama_gamer

    iama_gamer Active Member

    Messages:
    404
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #15
    yes that will work. Just add to .htaccess but you need to enable mod_rewrite.
     
    iama_gamer, Dec 2, 2009 IP
  16. yogi31286

    yogi31286 Active Member

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #16
    Last edited: Dec 2, 2009
    yogi31286, Dec 2, 2009 IP
  17. boymc

    boymc Well-Known Member

    Messages:
    133
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    113
    #17
    using google webmaster to direct all your domain.
     
    boymc, Dec 2, 2009 IP
  18. yogi31286

    yogi31286 Active Member

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #18
    yes... i know that method too...
    but if i use it then what about BING and yahoo?
    they will consider my site have two url's!!!
     
    yogi31286, Dec 3, 2009 IP
  19. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #19
    The link you gave, same effect with the code I gave you :p
     
    Dondon2d, Dec 3, 2009 IP
  20. anakrantau

    anakrantau Member

    Messages:
    195
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #20
    anakrantau, Dec 3, 2009 IP