Redirecting Blog Posts on a Subdomain to a Blog on the Main Domain using .htaccess

Back when I migrated over from Tumblr to WordPress, I also made the decision to switch my blog from to Originally I had planned to put other stuff on the landing page and keep the blog separate, but I have since realized that using the main domain as a landing page to the blog is of much more use.

After spending (what I thought) was too much time on it during the migration, I ended up deciding that it probably wasn’t worth the effort considering I couldn’t imagine there would be many sites linking to the old blog. Unfortunately, I noticed some random Blackberry forum post was linking to the subdomain, and it annoyed me that those poor guys were getting a 404 error, so I recently ended up trying to figure out why my use of 301 redirects didn’t seem to be working.

My initial effort to map my old Tumblr post URLs to the new WordPress ones didn’t go as swimmingly as I had hoped. The URLs I had for Tumblr had a different structure than what I chose for WordPress, and I was able to use the Simple 301 Redirects plugin to map the changes.



While this was a manual process, I only had 10 to 15 posts to map. Unfortunately, this only seemed to work when the URLs were on the same domain. When I tested the Tumblr example URL above, it would simply show a 404 error page on I had set up a subdomain to redirect to the main domain in my DNS, so I couldn’t see why it wouldn’t redirect the subdomain to the main domain (maintaining the URL path), and then resolve the post based on that.

With renewed energy (a month later), I started playing around with my DNS records again, gave up, and then found this post that turned out to solve my problem. It turned out that I also needed to modify the .htaccess file to add the following 301 redirect from the subdomain.

RewriteCond %{HTTP_HOST} ^$ [OR]

RewriteCond %{HTTP_HOST} ^$

RewriteRule (.*)$$1 [R=301,L]