Mod Rewrite htaccess from NON-WWW to WWW is not working

Discussion in 'Apache' started by daabomb2002, Aug 8, 2007.

  1. #1
    ok i'm trying to redirect my domain http://iphonewifihotspots.info to this:

    www.iphonewifihotspots.info
    (so includes the WWW)


    I tried this:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.iphonewifihotspots\.info [NC]
    RewriteRule ^(.*) http://www.iphonewifihotspots.info/$1 [L,R=301]

    But it doesn't work. It justs go to this:

    http://www.iphonewifihotspots.info/iphonewifihotspots/
    (it has a forward slash after it and some more text. and it is 404 page not found)

    I've also tried this:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.iphonewifihotspots\.info$ [NC]
    RewriteRule ^(.*)$ http://iphonewifihotspots.info/$1 [R=301,L]


    But it still doesn't work. it goes to this:
    http://www.iphonewifihotspots.info/iphonewifihotspots/
    (which goes to 404 page not found)




    What is wrong? I'm hosted with hostgator on a shared server.
     
    daabomb2002, Aug 8, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Those codes look more like you're trying to get rid of the www!!!

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^iphonewifihotspots\.info [NC]
    RewriteRule ^(.*)$ http://www.iphonewifihotspots.info/$1 [R=301,L]
     
    Nintendo, Aug 8, 2007 IP
  3. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #3
    RewriteEngine on

    RewriteCond %{HTTP_HOST} !^www\.iphonewifihotspots\.info [NC]
    RewriteRule (.*) http://www.oiphonewifihotspots.info/$1 [R=301,L]
     
    bouncer69, Aug 9, 2007 IP
  4. daabomb2002

    daabomb2002 Peon

    Messages:
    431
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i've solved my problem. i was modifying the htaccess from my public html folder when i should have been modifying the htaccess in my subdomain folder.
     
    daabomb2002, Aug 10, 2007 IP