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

htaccess file Help

Discussion in 'White Hat SEO' started by MixerDJ, Aug 20, 2014.

  1. MixerDJ

    MixerDJ Regular Member

    Joined:
    Nov 20, 2012
    Messages:
    374
    Likes Received:
    147
    Hi Guys,

    i need to redirect my non www version to www version. but in my htaccess file is having this code already


    I tried to add this code to redirect to www version but it says you are having redirect loop and site is not loading

    I need to know where to add this code?

    should i need to keep both codes or can someone correct my codes? :eek:

    Thank you guys !!:)
     
  2. sandersonford

    sandersonford Junior Member

    Joined:
    Jun 10, 2014
    Messages:
    131
    Likes Received:
    2
    delete old htaccess code and put in that
     
    • Thanks Thanks x 1
  3. yalokin

    yalokin Junior Member

    Joined:
    Apr 4, 2014
    Messages:
    119
    Likes Received:
    38
    From WordPress 2.4+ (maybe) theres a feature called "canonical URLs" which will 301 redirect www to non-www or vice-versa automatically for you. You don't need to change the htaccess file.

    Wordpress is taking care of this, so keep the original wp htaccess file:

    Code:
    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    
    
    # END WordPress
    And just change the WordPress address (URL) and Site address (URL) from ADMIN > Settings > General to start with www.

    For example http://mydomain.com becomes http://www.mydomain.com

    Just to note that when making such changes on indexed site you may want to take care of some additional details one of which is telling WMT which version to prefer when crawling to avoid duplicate content.

    Hope that helps.
     
    • Thanks Thanks x 2
    Last edited: Aug 20, 2014
  4. MixerDJ

    MixerDJ Regular Member

    Joined:
    Nov 20, 2012
    Messages:
    374
    Likes Received:
    147
    Thank you buddy it worked :D
     
  5. chiekobaumgartner

    chiekobaumgartner Newbie

    Joined:
    Aug 21, 2014
    Messages:
    3
    Likes Received:
    0
    you save my life yalokin, i'm stucking here for 4 days and you help me out
     
  6. rankwatch12

    rankwatch12 Regular Member

    Joined:
    Jun 19, 2014
    Messages:
    235
    Likes Received:
    13
    Home Page:
    You need to change WordPress address & Site address.

    This is found in admin, then settings and change the default url to start with www.