Moved a WordPress installation and it's linking to the wp-upload folder?

Posted Sep 16, 2011 | ~2 minute read

UPDATED : I rushed this one out. I'm now adding more meat to the bones on what this post is about!

If you use a development environment for the WordPress sites you build you may have come across a rather annoying issue. When you move the WordPress site to the live environment, any links to assets, such as uploaded documents or images are still relative to the development environment. Depending on how many links you have, you may just choose to re-link all the files / images to the new address. However, when you start working with hundreds of assets, it's a lot of work to run through.

Alas, no worries. There's an easy fix.

I recently moved a WordPress installation from "development" to "live" and was having great issues with the FTP server konking out every 2 minutes. Rather than duplicating folders and folder structures (which is a nasty hack) whack this gem of a redirect into your .htaccess file on the root of your server, and you'll be away :

RewriteEngine on
RewriteRule ^FOLDER/(.*?)/?$ NEWFOLDER/$1 [L]

This code simply routes any request for a file in the old folder to a new folder. For example, say your development site was in a folder named "dev", the code would be :

RewriteEngine on
RewriteRule ^dev/wp-content/(.*?)/?$ wp-content/$1 [L]

I hope this helps!

This code was kindly put under my nose by my good developer chap @samwilliamh on twitter.