Remove www. before sitename

Discussion in 'Bing' started by tigersoft, Sep 4, 2006.

  1. #1
    tigersoft, Sep 4, 2006 IP
  2. MilesB

    MilesB Well-Known Member

    Messages:
    1,813
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    180
    #2
    You need to make a mod_write
     
    MilesB, Sep 4, 2006 IP
  3. max_p

    max_p Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    try this:

    In the .htaccess-file:

    RewriteEngine on

    RewriteCond %{HTTP_HOST} !^www\.site\.com$
    RewriteRule ^(.*)$ http://site.com/$1 [L,R=301]​

    ("site" should be your site of course)
     
    max_p, Sep 4, 2006 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,808
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #4
    at http://5nz.com I use
    XBitHack      Off
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.5nz\.com [NC]
    RewriteRule ^(.*)$ http://5nz.com/$1 [L,R=301]
    
    Code (markup):
     
    sarahk, Sep 4, 2006 IP
  5. justtupeu

    justtupeu Peon

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Or here's a plain php code you can use :

    <?php
    if(stristr($_SERVER["HTTP_HOST"], 'www')){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://non-www-url" . $_SERVER["REQUEST_URI"]);
    exit();
    }
    ?>
    Code (markup):
     
    justtupeu, Sep 4, 2006 IP
  6. tigersoft

    tigersoft Peon

    Messages:
    164
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I have write it to .htaccess want to know one thing more. After writing this to .htaccess does this also changes the url in internet explorer. When i type www.sitename.com will this automatic change to http://sitename.com in internet explorer after writing this to .htacess?

    Cause it does not change, but i dont need to change it. Just want to index the site without www. to search engine.

    Thanks
     
    tigersoft, Sep 4, 2006 IP
  7. TechEvangelist

    TechEvangelist Guest

    Messages:
    919
    Likes Received:
    140
    Best Answers:
    0
    Trophy Points:
    133
    #7
    If it is not changing in your browser's address window, it is not working correctly. With a 301 redirect, you should see the address change.

    Not all hosting companies allow you to do server overrides with the .htaccess file, and it will only work on a Linux or Unix server running Apache.
     
    TechEvangelist, Sep 4, 2006 IP
  8. tigersoft

    tigersoft Peon

    Messages:
    164
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I want to know where i have to put this code? In .htaccess? or in my index.html main file?
     
    tigersoft, Sep 5, 2006 IP
  9. activeimedia

    activeimedia Well-Known Member

    Messages:
    920
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    110
    #9
    good stuff
    needed this myself
    got a site that shows PR5 with WWW and PR3 without it
     
    activeimedia, Sep 5, 2006 IP
  10. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Put this code in the .htaccess file under root ( public_html )
    Subsitute domain and .com with your values...

    
    ## Custom direct all to http
    
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
    
    Code (markup):
     
    agnivo007, Sep 5, 2006 IP
  11. tigersoft

    tigersoft Peon

    Messages:
    164
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I put this code in .htaccess and it worked. It changed the url to http://sitename.com but the problem is it does not load the site. It stop after changing the url in internet explorer. A little bit of more code, thanks.
     
    tigersoft, Sep 5, 2006 IP
  12. WinterWind

    WinterWind Peon

    Messages:
    122
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Sorry for the intrusion tigersoft, but I would like to know what to do getting the inverse results, site going to www instead.

    My site is best ranked with the www, so just wandering
     
    WinterWind, Sep 5, 2006 IP
  13. tyggemannen

    tyggemannen Guest

    Messages:
    842
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #13

    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^yourdomain\.com
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=permanent,L]
     
    tyggemannen, Sep 5, 2006 IP
  14. WinterWind

    WinterWind Peon

    Messages:
    122
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Thank you chowbow,

    Your help is much appreciated :)
     
    WinterWind, Sep 5, 2006 IP
  15. tyggemannen

    tyggemannen Guest

    Messages:
    842
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #15
    anytime : )
     
    tyggemannen, Sep 5, 2006 IP
  16. Dabs

    Dabs Peon

    Messages:
    115
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    I kinda prefer my own sites to retain the "www" instead of without. It seems more people are apt to recognize it (as opposed to links.) on offline advertisements.
     
    Dabs, Sep 7, 2006 IP
  17. seoindia

    seoindia Notable Member

    Messages:
    1,684
    Likes Received:
    101
    Best Answers:
    0
    Trophy Points:
    200
    #17
    why you need to do that?
     
    seoindia, Sep 7, 2006 IP
  18. tyggemannen

    tyggemannen Guest

    Messages:
    842
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #18
    I also use the www. maybe just of an old habbit, its looks much nicer without, and its easyer too.
     
    tyggemannen, Sep 7, 2006 IP
  19. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #19
    Be careful when doing this redirect as search engines see both www and non-www as different sites and if you have a ranking with www version for some keyword, you run the risk of loosing the position.
    Bye :)
     
    JEET, Sep 7, 2006 IP
  20. tyggemannen

    tyggemannen Guest

    Messages:
    842
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #20

    No, the point of doing this redirection is to make the seach engines see both the www and the non-www as one site. Thus making it stronger by collecting all incoming links to one domain.
     
    tyggemannen, Sep 7, 2006 IP