How to permantly redirect www to non www?

Discussion in 'Search Engine Optimization' started by PinoyIto, Feb 6, 2009.

  1. #1
    I can't find the write code that I will add to my .htaccess file. I know seo experts in this forum can help me with this.

    How can I permanently redirect all pages of my site from the url with www to with no www

    for examample www.mydomain.com - domain.com , www.domain.com/page.html - domain.com/page.html

    thanks in advance
     
    PinoyIto, Feb 6, 2009 IP
  2. mbreezy

    mbreezy Active Member

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #2
    I never understood why people want to remove their www. from the URL - then again I don't know why I want to add it. lol I like it.

    Anywho, here's the code to do the exact opposite; add the www. Alter it a little and test out on your page. I hope this helps as a starting point.



    RewriteCond %{HTTP_HOST} !^www.munnyness.com$
    RewriteRule ^(.*)$ http://www.munnyness.com/$1
     
    mbreezy, Feb 6, 2009 IP
  3. seodilip

    seodilip Active Member

    Messages:
    697
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #3
    you can do 301 Permanent Redirection From Non-www to www.
     
    seodilip, Feb 6, 2009 IP
  4. PinoyIto

    PinoyIto Notable Member

    Messages:
    5,863
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    260
    #4
    How can I do that?
     
    PinoyIto, Feb 7, 2009 IP
  5. Chuckun

    Chuckun Well-Known Member

    Messages:
    1,161
    Likes Received:
    60
    Best Answers:
    2
    Trophy Points:
    150
    #5
    PionyIto, just put the two lines of rules/code that mbreeze supplied you with into your root .htaccess file, and it'll do exactly what you've asked :)

    Hope this clears it up :)

    Chuckun
     
    Chuckun, Feb 7, 2009 IP
  6. Hiro Nakamura

    Hiro Nakamura Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    Code (markup):
    That should do the trick.
     
    Hiro Nakamura, Feb 7, 2009 IP
  7. linkcash

    linkcash Greenhorn

    Messages:
    70
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #7
    Put this code on top line of your .htaccess file

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.changeitwithyourdomainname\.com$ [NC]
    RewriteRule ^(.*)$ http://changeitwithyourdomainname.com/$1 [L,R=301]
    Code (markup):
    This will redirect www to non-www
     
    linkcash, Feb 7, 2009 IP
  8. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #8
    Contact your domain hoster. Many provide this option as part of their services. I use GoDaddy and when I set up my domain with them I configured "www" to always point to the non-"www" domain name which is the domain name I use.
     
    mmerlinn, Feb 7, 2009 IP