Jan 31 2008

Moving blogs and .htaccess

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.

Trackback URI Comments RSS

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite="" title=""> <code> <em> <i> <img alt="" src=""> <li> <ol> <p> <span> <strike> <strong> <ul>