WordPress Relocate plugin
Do you work on your website in a staged environment or sandbox? I do! I am always tinkering with new versions of my sites on a local server before deploying them to ‘live’.
WordPress, however, is very much tied to the URL you install it on. There are two options in the database, ’siteurl’ and ‘home’, that refer to the URL of your website. The upshot of this is that all the links in the sandboxed versions of my site keep pointing back to the live site. What a pain in the bum.
There are a few ways to deal with this. One of them is to define ‘RELOCATE’ in your wp-config.php. Then, when you visit wp-login.php, ’siteurl’ is changed to the new address. However, this doesn’t change ‘home’, so it’s only half the problem solved.
Another solution to the problem is to define ‘WP_SITEURL’ and ‘WP_HOME’ in your wp-config.php, which overrides whatever’s in the admin page. This certainly does the job, although you’ll have to have different versions of these defines in all of your staged environments.
So, here’s MY solution to the problem: a plugin which does all the leg work for you. Enable it, add ‘RELOCATE’ to your wp-config.php, and forget about it: all your sandboxes will magically work!
History:
- v0.1 (30th September 2007): First released version.
- v0.2 (30th September 2007): Fixed a bug related to existing users of RELOCATE, and people with WordPress not in their root dir.
Download:
Compatible with WordPress 2.2 and 2.3, and probably earlier versions too.
Just to clarify. This is how *I* use this plugin (on several of my sites):
1) Install it on the live copy and activate it.
2) Make a copy of your live site back in to your sandbox (be that on a remote test server or a local test server). Obviously now the plugin is on both test and live.
3) Clone the live database on to your sandbox / test copy. (This is why you activated it on live: so that it’s activated on test too).
4) Visit http://www.yourtestcopy.whatever/wp-login.php (this is the step that makes the plugin do it’s magic)
5) Use the test copy for your evil experiments.
Then, in the future, you can make clones of the database from the live copy whenever you like, and all you have to do after each one is visit /wp-login.php once.