I want all my pages to www.mydomain.com/page

Discussion in 'Site & Server Administration' started by kalle437, Feb 10, 2007.

  1. #1
    Hello there!
    I have own a blog, http://www.bitsniff.com/blog. The problem with this blog is that all pages are bitsniff.com, but I want them to be www.bitsniff.com.

    I have been trying with:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^(.*)\.bitsniff\.com\/blog\/$ [NC]
    RewriteRule ^(.*)$ http://www.bitsniff.com/blog/$1 [R=301,L]
    Code (markup):
    But I get errors.

    What I want is to reflag all the current pages in the blog from non-www to www. Is this possible?
     
    kalle437, Feb 10, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your best bet is to update the blog to create links with the www. If you still want all existing external links (and SEs) to get redirected, you can use htaccess. Otherwise you'll double the requests on your server every time someone browses your blog.

    For the htaccess, HTTP_HOST only contains the hostname (i.e. www.domain.com, sub.domain.com, domain.com), not the whole URL. All you need to do is match it against not starting with 'www'. In the blog directory .htaccess:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.bitsniff.com/blog/$1 [R=301,L]
    Code (markup):
     
    rodney88, Feb 10, 2007 IP
  3. kalle437

    kalle437 Peon

    Messages:
    283
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That works. What happens is if I enter bitsniff.com/blog/randompage I get back to the index of the blog. But that is a problem. Because all links to articles, pages and archives in the blog is pointing to non-www pages, so if you click archives, you come to index.

    How do I change all the links to www, instead of non-www? :) I am using WordPress.
     
    kalle437, Feb 10, 2007 IP