Support » Fixing WordPress » Redirect to get rid of www.

  • I installed the no www plugin and ended up with a problem so I uninstalled it.

    Right now my site with www. on is a PR 4 and without is a PR 5. I would like everything forwarded to without www. My blog is located at That is the main page of the site. I am not sure how to edit my htaccess files to remove the www permanently. I had bluehost do it and they majorly screwed everything up.

    root directory htaccess file

    Redirect /home.htm

    RewriteEngine ON
    RewriteCond %{HTTP_HOST} ^$ [OR]
    RewriteCond %{HTTP_HOST} ^$
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^(.*)$ [R=301,L]
    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    /blog htaccess file

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • All you need is this, with the example sites used changed to your site.

    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^www\.yourdomainhere\.com [nc]
    rewriterule ^(.*)$$1 [r=301,nc]

    Place it in your .htacess file, remove anything else that attempts to do the same thing, and you should be good.

    I just use the Enforce www preference plugin. By far the easiest way to go about it, in my opinion.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    The .htaccess that waffles gave is by far the best way to do it. Fast, efficent, doesn’t require any real processing time…

    That .htaccess should go in the root of your site, BTW. It doesn’t need to be anywhere else, usually.

    More info can be found here:

    Thanks everyone.

    the www enforce plugin actually caused me a to have a ton of problems that I could not fix. I researched and learned that the htaccess file is the way to do it. I have read the site but I am pretty clueless on this stuff and scared after my bad experience with www enforce plugin.

    Waffles, when you say to remove anything else that does the same thing do you mean the plugin or do you mean something else in the htaccess file.

    in the header.php, first line after <?php , i added this line:

    $url = "http://".$_SERVER['HTTP_HOST'];
    $realurl  = "";
    if($url != $realurl){

    change to your domain. this one is OK when your cookies save your url without www. i had that problem so i took this code.

    not the best, but it works for me.


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect to get rid of www.’ is closed to new replies.