redirect www to non-www

by monere
14 replies
Hi,

I just "preferred" the non-www version of my site in the Google Webmaster Tools, and despite of this fact it still won't redirect properly. Anybody knows what might be wrong?

Note: I've done this same thing dozens of times before, and it worked flawlessly every time, but this time it just won't work

I have a hunch this is something htraccess related, but since I know very little about programming and stuff, and since htaccess is such a sensible beast where even a lousy blank space can ruin everything, I thought I'd ask before dealing with the file (in case it really is the htaccess file that's causing this)

If anybody has any idea why it won't redirect to non-www, please let me know.

Thanks in advance
#nonwww #redirect #www
  • Profile picture of the author murrad
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

    It is the universal script and must work good..If still problem occurs check with your provider whether Apache Rewrite Module turned on. It is very essential to redirect.
    Signature

    Environment friendly Paper cup machine

    {{ DiscussionBoard.errors[4800517].message }}
    • Profile picture of the author monere
      Originally Posted by murrad View Post

      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^domain.com
      RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

      It is the universal script and must work good..If still problem occurs check with your provider whether Apache Rewrite Module turned on. It is very essential to redirect.
      Ok, thanks. But, where exactly I put this code??

      Here's how my htaccess file looks like right now
      # 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
      Signature

      Try not to become a man of success but rather to become a man of value - Albert Einstein

      {{ DiscussionBoard.errors[4800657].message }}
      • Profile picture of the author ChristiN
        Hi monere,

        You'll want to place that code above the # BEGIN WordPress line in your .htaccess file.

        Hope this helps!
        {{ DiscussionBoard.errors[4806895].message }}
        • Profile picture of the author monere
          Originally Posted by ChristiN View Post

          Hi monere,

          You'll want to place that code above the # BEGIN WordPress line in your .htaccess file.

          Hope this helps!
          Yes, it helps. Thank you
          Signature

          Try not to become a man of success but rather to become a man of value - Albert Einstein

          {{ DiscussionBoard.errors[4807215].message }}
  • Profile picture of the author icantsaymyname
    yes,the .htaccess file controle the 301
    {{ DiscussionBoard.errors[4825611].message }}
  • Profile picture of the author maheshhari
    Google considers a site with WWW and without WWW as different sites. So, you must add the code into your .htaccess file or else some content duplication issues will arise.

    If you can't find .htaccess file, just install the "Robots Meta" plugin and you can directly edit the file using it.
    {{ DiscussionBoard.errors[4828135].message }}
    • Profile picture of the author monere
      Originally Posted by maheshhari View Post

      Google considers a site with WWW and without WWW as different sites. So, you must add the code into your .htaccess file or else some content duplication issues will arise.

      If you can't find .htaccess file, just install the "Robots Meta" plugin and you can directly edit the file using it.
      this doesn't answer my question at all, but thanks ... I guess
      Signature

      Try not to become a man of success but rather to become a man of value - Albert Einstein

      {{ DiscussionBoard.errors[4828255].message }}
  • Profile picture of the author cannons
    Just google for the correc htaccess code

    copy paste it will definitely work always works for me
    {{ DiscussionBoard.errors[4870813].message }}
    • Profile picture of the author monere
      Originally Posted by cannons View Post

      Just google for the correc htaccess code

      copy paste it will definitely work always works for me
      I already googled it and found something, just not sure if it works flawlessly. All I know it doesn't return me the usual "internal server error" pages like other times when I entered other codes, but I am still not convinced that "redirect 301 http://olddomain.com/oldpage.php http://newdomain.com/newpage" is the correct code.

      But like I said, the website seems to not return error pages anymore with this code installed, and that's nice

      Thanks for the reply.
      Signature

      Try not to become a man of success but rather to become a man of value - Albert Einstein

      {{ DiscussionBoard.errors[4871041].message }}
  • Profile picture of the author SupporTech
    the answer is also not related in the topic title, what you did is redirection an errordocument for error 301, that doesnt answer the topic question!

    I think this does!:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^w|ww.d|omain.com$ [NC]
    RewriteRule ^(.*)$ htt|p://domain.com/$1 [R=301,L]


    Remove the " | " (w/o the quotes)
    by Murrad
    {{ DiscussionBoard.errors[4890441].message }}
  • Profile picture of the author DavidWincent
    You can try the following script. It is a universal script. Check if it works.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
    RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
    Signature
    Webmaster Studio -A premier web design and internet marketing company in New York.
    {{ DiscussionBoard.errors[4890981].message }}
  • Profile picture of the author monere
    thanks for both your replies SupporTech and DavidWincent.

    I will place these codes and see which one does it. But, I still am confused about where I should insert the code. Currently, I have a standard htaccess file for my Wordpress sites that starts with "# BEGIN Wordpress", then there are some conditions and rules, and then it ends with "# END Wordpress".

    Should I paste this code between the "begin" and "end" tags, just below the other code, or should I enter it (like someone else said) right at the start of the file (even before the "# BEGIN Wordpress" line)?

    Could you please tell?

    Thanks again
    Signature

    Try not to become a man of success but rather to become a man of value - Albert Einstein

    {{ DiscussionBoard.errors[4891128].message }}
  • Profile picture of the author SupporTech
    Yeah, It's quite necessary to place the code, cuz when you messed up, everything seems to be a problem, try to put it at the last part and see if that happens to work!
    {{ DiscussionBoard.errors[4895977].message }}
  • Profile picture of the author George Curtis
    Monere,

    PM me and I will be glad to help you if you are having further problems with this.

    We do it all the time and actually prefer the non-WWW for several reasons (not related to SEO).

    If you already have it working, then great.
    Signature

    George-C

    THE BEST WORD-PRESS POPUP PLUGIN EVER RELEASED! - "MOW POP"

    {{ DiscussionBoard.errors[4895990].message }}

Trending Topics