1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

non www to www?

Discussion in 'White Hat SEO' started by Dr.Sell, Aug 4, 2010.

  1. Dr.Sell

    Dr.Sell Newbie

    Joined:
    Nov 2, 2007
    Messages:
    29
    Likes Received:
    4
    Hi, i have a problem to add 301 redirect from non www to www please can someone please help me on what for your information this my htaccess file.


    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    Thanks,
     
  2. chockomonkey

    chockomonkey Regular Member

    Joined:
    Mar 27, 2009
    Messages:
    366
    Likes Received:
    40
    Location:
    the States
    This works for my sites, stole it off the internet from somewhere.

    Code:
    RewriteEngine on 
    Options +FollowSymLinks
    
    RewriteCond %{HTTP_HOST} ^yourwebsite.com [NC] 
    RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [L,R=301]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.html$ http://www.yourwebsite.com/$1 [R=301,L] 
    
     
  3. Dr.Sell

    Dr.Sell Newbie

    Joined:
    Nov 2, 2007
    Messages:
    29
    Likes Received:
    4
    hi thank you,i add it after this
    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
     
  4. chockomonkey

    chockomonkey Regular Member

    Joined:
    Mar 27, 2009
    Messages:
    366
    Likes Received:
    40
    Location:
    the States
    I don't know enough about .htaccess files or what's written in them. But the code i wrote above is the only text i have in the entire file. I don't know what the code you have even does, if anything. Hopefully an expert can chime in here.
     
    • Thanks Thanks x 1
  5. Dr.Sell

    Dr.Sell Newbie

    Joined:
    Nov 2, 2007
    Messages:
    29
    Likes Received:
    4
    ok no prob thank's.
     
  6. dragos

    dragos Junior Member

    Joined:
    Jan 27, 2008
    Messages:
    162
    Likes Received:
    25
    Occupation:
    seo google
    Location:
    España
    Home Page:
    I prefer using webmasters tool to say google what is my prefered url
     
  7. chockomonkey

    chockomonkey Regular Member

    Joined:
    Mar 27, 2009
    Messages:
    366
    Likes Received:
    40
    Location:
    the States
    You should do both!

    Mr. Sell, *cough* excuse me... Doctor... you should do both.
     
  8. GreyWolf

    GreyWolf Executive VIP Jr. VIP

    Joined:
    Aug 17, 2009
    Messages:
    1,930
    Likes Received:
    5,389
    Gender:
    Male
    Occupation:
    Artist / Craftsman
    Location:
    sitting at my PC
    I would put the code chocomonkey gave you at the top of your htaccess file and then the wordpress code after.
     
  9. jartym

    jartym Junior Member

    Joined:
    May 22, 2008
    Messages:
    120
    Likes Received:
    8
    Recently I redirected my site and it works well. Try this command in .htaccess file:Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^yoursite.com [nc]
    rewriterule ^(.*)$ http://www.yoursite.com/$1 [r=301,nc]
     
  10. jartym

    jartym Junior Member

    Joined:
    May 22, 2008
    Messages:
    120
    Likes Received:
    8
    Recently I redirected my site and it works well. Try this command in htaccess file:
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^yoursite.com [nc]
    rewriterule ^(.*)$ http://www.yoursite.com/$1 [r=301,nc]