How to disable redirect on test/staging copy of wordpress site

WordPress stores the domain name of your site in the database (wp_options table among others). If you just copy the site and database the site will redirect to the domain mentioned in the database.

Option 1 : Using a php tool

You can do a search and replace using a proper tool to replace www.mydomain.com with test.mydomain.com (https://interconnectit.com/search-and-replace-for-wordpress-databases/ is one such tool).

Option 2 – Use a plugin

One of the backup plugins that will do this for you. You would install the backup plugin on the live site, create the backup file on your live site using the plugin. One the test site you would install a clean version of WordPress, install the same backup plugin, and then do a restore. (example plugin: https://en-gb.wordpress.org/plugins/updraftplus/)

Remember: Every WordPress install will need it’s own database.

Leave a Comment