• 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 mioaklandcounty.com/blog. 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 http://www.mioaklandcounty.com/blog/

    RewriteEngine ON
    RewriteCond %{HTTP_HOST} ^975fairfax.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.975fairfax.com$
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^(.*)$ http://www.oakland-county-homes.com/listing/47877522 [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]
    </IfModule>
    # 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 ^(.*)$ http://yourdomainhere.com/$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)

    WordPress.org 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:
    http://no-www.org

    Thread Starter maureenfrancis

    (@maureenfrancis)

    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 no-www.org 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:

    <?php
    $url = "http://".$_SERVER['HTTP_HOST'];
    $realurl  = "http://yoursite.com";
    
    if($url != $realurl){
    header("Location:".$realurl);
    exit;
    }
    ?>

    change http://yoursite.com 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.

    cheers

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