redirect from http://mysite.com to http://www.mysite.com?

Discussion in 'Apache' started by gford, Nov 22, 2005.

  1. #1
    gford, Nov 22, 2005 IP
  2. Dekker

    Dekker Peon

    Messages:
    4,185
    Likes Received:
    287
    Best Answers:
    0
    Trophy Points:
    0
  3. gford

    gford Peon

    Messages:
    1,188
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks much for that URL.

    That works for my normal HTML site and great.

    But I have MAMBO sites and it doesn't appear to work for that. Any thoughts on that?
     
    gford, Nov 23, 2005 IP
  4. Dekker

    Dekker Peon

    Messages:
    4,185
    Likes Received:
    287
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Does mambo use any .htaccess stuff?

    I tried turning on the hard links on my wordpress with this hack on and it stopped working.
     
    Dekker, Nov 23, 2005 IP
  5. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try this mod_rewrite trick in your .htaccess file:

    RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
    RewriteRule ^(.*) http://www.yourdomain.com/$1 [L,R=301]
     
    ServerUnion, Nov 23, 2005 IP
  6. gford

    gford Peon

    Messages:
    1,188
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Fantastic post! This works with mambo.
     
    gford, Nov 25, 2005 IP
  7. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I know, this is a great piece of mod_rewrite. Thank me with some green ;)
     
    ServerUnion, Nov 28, 2005 IP
  8. gford

    gford Peon

    Messages:
    1,188
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Umm, I already did! :)
     
    gford, Nov 28, 2005 IP
  9. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I was meaning the other green, money! No, glad you found a use for the code.
     
    ServerUnion, Nov 28, 2005 IP
  10. netmaster123

    netmaster123 Well-Known Member

    Messages:
    1,852
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    140
    #10

    You can use this code:
    <META HTTP-EQUIV="Refresh"
          CONTENT="5; URL=html-redirect.html">
    PHP:
    I use it on my teen sexuality website and it works very well, you can also edit your .htaccess file or you can use cpanel to setup a basic redirection.
     
    netmaster123, Aug 27, 2006 IP
  11. gford

    gford Peon

    Messages:
    1,188
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #11
    This is what I use:
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
    RewriteRule ^(.*) http://www.mysite.com/$1 [L,R=301]
    Code (markup):
    in .htaccess
     
    gford, Aug 28, 2006 IP
  12. blabla11

    blabla11 Peon

    Messages:
    164
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #12
    how to redirect from www to non www?
    thank you!
     
    blabla11, Dec 9, 2006 IP