I keep making WordPress sites on temporary domains (say: example.com), and then to go live with them, I just move entire installation to new server and change temporary domain to live domain (say: mysite.com). This is easy.

I, however, wonder how all the internal links (say: example.com/hello) inside posts' and pages' content of WordPress automatically get rid of old temporary domain and get replaced with new live domain (mysite.com/hello) and things just keep working? Is there any automatic script which keeps track of the setup domain, and updates all the domained links in all posts as soon as main domain changes?

2 Answers 2


I suppose it's possible to create a script or plugin that would monitor the WP settings URLs in Dashboard >> Settings >> General and do a global change when needed, but such a script would be complex ad fraught with issues when handling the different img and a href links in post/page content, as well as in all the tables - plain text and serialized - in the database.

It's not difficult or time consuming to change the site URLs the usual way. The best references are the WP docs at http://codex.wordpress.org/Moving_WordPress

When Your Domain Name or URLs Change

When your domain name or URLs change - i.e. from http://example.com/blog to http://example.com, or http://example.com to http://example.net - there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display.

If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options:

1) Only perform a search and replace on the wp_posts table.

2) Use the https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ Search and Replace for WordPress Databases Script to safely change all instances.

Or search for various plugins that do much of the work for you: http://wordpress.org/plugins/ There are several to choose from, including premium (paid) plugins via a Google search.


The URLS are generated based on home_url() and site_url(), which are in the settings page.

Codex: site_url()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.