I have a website that I am rebranding and using a new domain name for. Right now it is primarily a blog hosted at the root.

I am going to be redirecting from www.old.com to www.new.com, and I also want to move my blog to blog.new.com. Currently www.old.com doesn't serve any subdomains.

Based on the research I've done, it would seem that I need to use 301 redirects because these should be permanent. I just don't really know what I need to do to setup these redirects. Should I use mod_rewrite?

My sites are hosted on Dreamhost so any Apache configuration that I would need to do I believe I'd have to do in an .htaccess file.

1 Answer 1


All of the following code will be placed in a file called .htaccess in your root web directory and mod_rewrite enabled on your server.

Changing the domain is easy to do. The following snippet should do it:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [R=301,L]

To move your blog you can use the following snippet (assuming your blog is in a subdiretory called /blog):

RewriteCond %{HTTP_HOST} ^blog\.old\.com$
RewriteCond %{REQUEST_URI} !^blog/
RewriteRule ^(.*)$ http://blog.new.com/$1 [L,QSA]
  • First part looks OK. I think his blog is currently in the root directory of www.old.com and he wants to redirect that to blog.new.com, so you might want to modify the second part. Hopefully he adds new content to the root of www.new.com or he'll end up with duplicate content issues.
    – dan
    Jan 15, 2014 at 2:19
  • Yep. I had that in my brain but it apparently didn't make it to y fingers.
    – John Conde
    Jan 15, 2014 at 2:22
  • Most of the time I have to edit questions in order to fully grasp them, and sometimes that still doesn't make it to my fingers ;-)
    – dan
    Jan 15, 2014 at 2:36
  • As far as I know, if he 301 redirects his old site to his new site, he won't have to worry about duplicate content issues. Jan 15, 2014 at 8:05
  • @IvovanderVeeken That was referring to the OP redirecting www.old.com, where the blog was located, to www.new.com, and also moving the blog to blog.new.com - the two would need to be different in order to avoid duplicate content.
    – dan
    Jan 15, 2014 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.