htaccess to send www to non www not working (3 posts)

  1. crakbot
    Posted 9 years ago #

    I've added the two different types of code to my .htaccess file to send www traffic to the non-www domain.

    Each version works fine for the index but all other pages get redirected to the index then as well.

    For example, if I type http://www.example.com it automatically goes to http://example.com, which is what I want. But if I type http://www.example.com/catagory/blog_post it gets redirected to http://example.com/index.php.

    All the codes I have found on-line to fix the www non-www canonical issue does this.

    What code do I use to redirect all traffic to the corresponding non-www URL, not just the index.

  2. MarkMichon
    Posted 9 years ago #

    Are you using the code from no-www.org? That's what I used when my blog was up and it went fine.

  3. waffles
    Posted 9 years ago #

    Put this in your .htaccess file.

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

    That should do the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic