Accidentally Changed WordPress Url

If you’re on a local install, it’s fairly trivial to fix this. Just use phpMyAdmin to reset home_url and/or site_url in the wp_options table in the database.

Switching between two localhost installs is also fairly straight-forward: just don’t actually use “localhost” for anything. Instead, set up a unique domain in your system’s hosts file for each install:

127.0.0.1    site1.localdomain
127.0.0.1    site2.localdomain

Then, in Apache, set each of these domains to point to your different installations (use your vhosts setup). Make sure site_url and home_url are set properly and you’re good to go.