We need to change domain url of a WordPress site in the following conditions:
- When we need to make live a localhost developmental site to its remote destination
- When we need to create a staging remote website (or shifting a staging website to a live website)
- When we are changing site address. (shifting a website from one to another domain or sub-domain)
For instance, I seek to implement major design changes to my WordPress such as changing the theme and applying the design changes to new theme. But at the same time I will never want visitors' experience disturbed- a disturbed experience that may arise due to any changing procedure. And nor will I want to put my website in maintenance mode as it will cause traffic loss.
There are many hosts that offer in-built site staging features:
With the staging tool offered by these hosts, you can create a staging version of your live website and then push the staging site to the live site any time at your convenience.
But just imagine a scenario that you have no tool (or a plugin like UpdraftPlus and BackupBuddy) to change WordPress website address, what will you do and what are your options? Either you try to change site address via phpMyAdmin or try a domain changer WordPress plugin. These methods do work but can’t change site address in many database tables.
Fortunately, now there is something you can bank upon: a small php script, a panacea to above problems, thanks to its developers Interconnectit. This php script is in fully functional mode and I have tested it myself. I have used it to create a staging website for webcusp.com and I didn’t find even a single link un-replaced.
Warning – You must take a full database backup of your WordPress before using this script.
How to use the PHP Script
- First of all, copy all WordPress files to the destination where you want to deploy your WordPress with changed site address
- Create a new database and import your existing WordPress database into this newly created database
- Update database detail in wp-config.php
- Download the PHP script and copy its folder in the same destination where you have copied WordPress
- type the following url in your browser address bar and hit keyboard ENTER button;
- replace blue text with your WordPress base url (where you have copied your WordPress files) and replace red text with the folder name that contains downloaded php script files (make sure you have updated domain namesevers if you move your WordPress from one to another host, otherwise script will not run)
- Script interface will open
- Add the old WordPress base url in “replace” field and current WordPress base url in “with” field
- Click on the “live run” button.
- Script will start working and within a few minutes it will finish the process.
- Open the new address in browser and check whether or not every link link is migrated to new address.
- After that, delete the script using “Delete me” button
This script may also be used to replace any text across your WordPress database. For example to replace an affiliate link.