When I first set my blog up, years ago, I installed it to a subdirectory called “/blog” with the vague intention that the canonical “http://heliologue.com” URI could be a landing page pointing to whatever else I wanted to put on my server. Eventually, I learned that I could get to just about anything I wanted using the blog, and used a PHP redirect to point the root URI to “/blog,” which worked well enough.
Eventually, though, I got tired of such a thing, and wanted the blog to reside on the root of my public HTML directory. At this point, though I had a large (sort of) number of incoming links and indexed pages. How would I move without breaking all those links.
Yesterday, I finally bit the bullet and moved my blog up a directory, but the mod_rewrite trick I had in place to prevent 404s didn’t work. Oh noes!
Finally, I stumbled upon this ridiculously simple solution for my .htaccess file:
RewriteEngine on RewriteBase / Redirect 301 /blog http://heliologue.com
And everything works. When someone goes to http://heliologue.com/blog/path/to/entry, the directive will automagically take them to http://heliologue.com/path/to/entry.
Might I add that once I changed the siteurl values in my database, I immediately rebuilt my site’s XML sitemap, which was easy with this little plugin, which will generate sitemaps for compatible search engines (Google, most importantly) and ping them with the change.