1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Wordpress blog redirect non www to www

Discussion in 'Apache' started by UnEmployedAfterSchool, Jun 13, 2006.

  1. #1
    Here is what i have so far in .htaccess, this created by Wordpress:

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

    # END WordPress

    I have tried the following, no success:


    redirect 301 mysite.com/old-file-name.htm http://www.mysite.com/old-file-name.htm
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.com [NC]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]


    Result is that it is going to my www.mysite.com not www.mysite.com/old-file.htm


    I have also tried this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www
    RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [L,R=301]
    # END WordPress
    SEMrush
    But none seem to work. It give not found error. can someone help me out. In Wordpress settings I have the following:

    Options -> General->Wordpress address: http://www.mysite.com
    Options -> General->blog address: http://www.mysite.com

    Permalink structure
    Custom

    Thanks,
     
    UnEmployedAfterSchool, Jun 13, 2006 IP
    SEMrush
  2. Cricket

    Cricket Well-Known Member

    Messages:
    182
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    155
    #2
    I am using the following before the rewrites:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
     
    Cricket, Jun 13, 2006 IP
  3. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #3
    There's an even easier way to do it, check out the www enforcer plugin by my friend Mark.

    http://txfx.net/code/

    it's a plugin that redirects for you, no htaccess editing involved...
     
    fsmedia, Jun 13, 2006 IP
  4. UnEmployedAfterSchool

    UnEmployedAfterSchool Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I just upload the into the plugin and activated.
    Question about this:

    "From now on, you can edit slugs without worry! If you have an old post whose slug you changed (prior to installing the plugin), you can manually add an old_slug Custom Field for that entry, and it will be forwarded."

    You mean I have to modify every old blog posting I have.

    My problem is this:
    google see my web as two: mysite.com and www.mysite.com
    msn has indexed my site as mysite.com/archieve/blah

    When I do the redirect so the traffic coming from msn will be directed from mysite.com/archieve/blah to www.mysite.com/archieve/blah. For some reason, links to the blog posting are displayed as not found
     
    UnEmployedAfterSchool, Jun 13, 2006 IP
  5. Cricket

    Cricket Well-Known Member

    Messages:
    182
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    155
    #5
    It takes about 5 seconds to add the code I gave you to your htaccess file to prevent this issue, but it must be added before the mod_rewrites listed.
     
    Cricket, Jun 13, 2006 IP
    GRIM likes this.
  6. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #6
    You're looking at the wrong plugin then, just look at this one: http://txfx.net/code/wordpress/enforce-www-preference/ -- that will give you everything you need. His /code/ page has a lot of other good plugins too, but the www-enforcer is what you need to resolve this.
     
    fsmedia, Jun 13, 2006 IP
  7. UnEmployedAfterSchool

    UnEmployedAfterSchool Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7

    Now the msn traffic are redirected as I like. Plugin is pretty good. So one final question: This plugin now force www.mysite.com. So that means, no mix up with google identifying my site as two: mysite.com and www.mysite.com

    Thank you.....
     
    UnEmployedAfterSchool, Jun 13, 2006 IP
  8. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #8
    Yep that's correct. Now whenver someone types in domain.com it will redirect to www.domain.com, same with robots. I use it for all my blogs so that there are never any pagerank discrepencies or anything..
     
    fsmedia, Jun 13, 2006 IP
  9. UnEmployedAfterSchool

    UnEmployedAfterSchool Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    UnEmployedAfterSchool, Jun 17, 2006 IP
  10. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hi,

    There are no links to /index.php in my WordPress blog, except the links to the search results which are /index.php?s=blahblah.

    If you do not link to /index.php yourself, as other sites will most probably link to /, there will be no problem.

    Jean-Luc
     
    Jean-Luc, Jun 18, 2006 IP
  11. Yardy009

    Yardy009 Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Hi folk,

    I want non www to www redirection for my one important WordPress blog. I have enabled the Permalink to make URL SEOF(Search Engine Optimization Friendly).

    I placed the below code in my .htaccess file which is located on web server root.

    But what all I get is "Redirect Loop" error in Firefox.


    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^mydomain.com[nc]
    RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    Am i missing anything ?

    A little help is appreciated.

    Thanks in advance

    Regards,
    Sachin Pethani(Web-Farmer)
    www.letsnurture.com
     
    Yardy009, Sep 17, 2009 IP
  12. rover

    rover Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    @Yardy009
    I have tested your .htaccess.

    It works on my blog.

    You just need to login to your wordpress blog, and change:

    Settings - General
    WordPress address (URL) : www.mydomain.com
    Blog address (URL) : www.mydomain.com

    That's all.
     
    rover, Nov 6, 2009 IP
  13. nasul

    nasul Peon

    Messages:
    102
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    The code works great for me.
     
    nasul, Nov 20, 2010 IP