I moved the old stuff to mhinze.com/archive but I wanted to ensure that my links still worked.. for SEO and also for usability. So I got all the post slugs from the Wordpress database and added them as redirects to /archive in .htaccess using sed. There’s probably a better way to do this but it was pretty easy.
[linux]$ mysql -u user -ppassword -h mysql.server.com
-Be "select post_name from wp_posts" blogdatabase
| sed 's/[a-zA-Z0-9\-]*$/Redirect 301 \/&\/ http:\/\/mhinze.com\/archive\/&/'
> .htaccess.new
[linux]$ cat .htaccess >> .htaccess.new
[linux]$ mv .htaccess.new .htaccess
I’m not too worried about slug collisions – I think that’s a rare case that I’ll address as needed.
So now http://mhinze.com/nhibernate-composite-element-mapping/, for example, redirects to the correct post in /archive
Leave a reply