Support » Fixing WordPress » 301 to non-www (instead of default 302)

  • I realize that a lot of people probably 301 from to – I’d like to do the opposite. I have backlinks pointing to both versions of the site, and I’d like to take full advantage of them.

    I’m pretty sure that by default, WP redirects via 302, which is a temporary redirect if I understand correctly. I know that a 301 can be achieved via .htaccess, not exactly sure how (seen it done from non-www to www, but not vice-versa).

    Anyway, I want to know what the best way to do this is, and also curious if this can potentially mess up my WP installation. Any help would be much appreciated. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Did some research over the weekend and I’m still not sure what the best solution for this is… Does anyone have any idea?

    What you’re looking for is mod_rewrite. There are plenty of howtos around that will hand the solution to you. Google is your friend here.

    I recommend the Apache reference, if you’re already atleast vaguely familiar with mod_rewrite

    But basically, this is what you’re after (mind you, this is off the top of my head and untested):

    RewriteEngine on # Turns on the RewriteEngine
    RewriteCond %{HOST} ^www\.host\.com$ # Match to your domain with www-host
    RewriteRule .*$1 [R=301] # Redirect to non www-host

    Good luck in your endeavors.


    Thanks for the help. I tried this, but I’m still getting a 302 redirect, at least according to this tool:

    Any idea what I may have done wrong? Could something else in WP be overriding the settings specified in my .htaccess file?

    Nevermind, I think I may have figured it out. I used:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.domain\.net [NC]
    RewriteRule ^(.*)$$1 [L,R=301]

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘301 to non-www (instead of default 302)’ is closed to new replies.