Forwarding www.mysite.com to http://mysite.com

Discussion in 'Programming' started by immortality, Jan 11, 2007.

  1. #1
    My website is set up so that http://mysite.com is the homepage and thats where I want all my visitors to go so it gets tracked on one tracker. The problem is ive got people typing www on the front so all my traffic isnt on one chart. Is there a way to redirect www traffic to just http://mysite.com so I can view all traffic on one page?
     
    immortality, Jan 11, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteCond %{HTTP_HOST} !^site\.com$ [NC]
    RewriteRule (.*) http://site.com/$1 [L,R=301]
    Code (markup):
    (from topic)

    Put that in a .htaccess file in the public_html or www folder (i.e. would be at site.com/.htaccess)
     
    rodney88, Jan 11, 2007 IP
  3. immortality

    immortality Peon

    Messages:
    1,512
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well I put that in my htaccess but it did nothing.
     
    immortality, Jan 11, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    "Well" you have to make sure you're setup for rewriting before using rewrite rules. And I assume you changed site.com to your domain. The whole thing then:
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^site\.com$ [NC]
    RewriteRule (.*) http://site.com/$1 [L,R=301]
    Code (markup):
     
    rodney88, Jan 11, 2007 IP
  5. immortality

    immortality Peon

    Messages:
    1,512
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I added "RewriteEngine on" and it worked. Thanks a lot for you help.
     
    immortality, Jan 11, 2007 IP