Redirecting With .htaccess

Posted on in Programming

Blue Two Arrow Road SignI use the Postalicious Wordpress plugin to automatically generate my Tech Messages posts. For some reason, the plugin went wonky last night and posted twice!

I don't really want two posts with the exact same content, so the second post had to go. Since the post had been live for 12 hours or so, I couldn't just delete it. After all, it was in feed readers and search engines and who knows what else. The best course of action was to redirect the duplicate post to the original post. This is easily done via a redirect in the .htaccess file in the root directory of my web site.

I've added the following line to my .htaccess: (Please note — no matter what your browser renders, this is just one line!)

redirect 301 /tech-messages/tech-messages-2007-09-19-2/ {filename}/tech_messages/

I've chosen to use a 301 redirect because the source page (/tech-messages/tech-messages-2007-09-19-2/) is redirecting to the destination permanently. Now, if you somehow stumble across a link for the duplicate page and follow it, you'll notice that the URL in your address bar has been rewritten to match the original post.


My Bookshelf

Reading Now

Other Stuff