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?
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):
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.