After migrating my blog over to Wordpress, files have moved around a bit. Sites that linked to files on my site (including Google Images, as a prominent example) now link into the void, which is a bit of a pain. As a partial solution, I’ve added some .htaccess rules to help route visitors to the right place:
Redirect 301 /feeds/index.rss2 http://atastypixel.com/blog/feed
Redirect 301 /feeds/atom.xml http://atastypixel.com/blog/feed
However, that doesn’t solve all problems – after I reorganised my uploads, files are located at a very different path to their original home. So, I added a short script which does a search for requested files if they can’t be found, then redirects visitors to the right file.
Here is the script, and an accompanying .htaccess file needed to hook into it:
To use it, put the script and the htaccess file into a folder on your site where you want it to take effect (for me, it went into ‘wp-content/uploads’). Then, modify the htaccess file – just set the RewriteBase field to the directory you’re in – and rename it to ‘.htaccess’.
Related posts
- Smart 404 for Wordpress Save visitors to your Wordpress site from unhelpful 404 errors!...
- Some useful mini-plugins for Wordpress Three simple Wordpress plugins that provide shortcode-based functionality: Simple Google...
- Re-organising/assembling uploads for Wordpress Migrating from Serendipity, I’ve had a few hiccups in data...
- Firming up Wordpress’s security Instructions on how to protect your Wordpress administration area with...
- Custom Permalinks Custom Permalinks is a Wordpress plugin that gives you ultimate...
One Comment
I know the pain of having to do 301 redirects for a new blogging platform. I wish there was a universal way to do it besides adding a different line for each web page in the htaccess file. It can take a “long” time if you have a ton of posts.