When testing WordPress sites for development, it is often common, to restore the whole site to a testsite ex. test.domin.com, but we do not want to allow search engines to read data and index things on the test site after restore, we will have to change the site url, else we will be redirected to the normal url.
Hardcoding site url:
Edit wp-config.php and add theese lines:
define('WP_HOME','http://test.domain.com'); define('WP_SITEURL','http://test.domain.com');
This is a quick and dirty fix, to force the site url to our test site, with this, it is not possible to change site url in settings within WordPress, cause it wil lbe greyed out, but remember, this is only for the test site and to force it to stay there.
Now for thoose indexing robots:
In WordPress you can set this setting (Discourage search engines from indexing this site):
And place a file called robots.txt in the root folder of the site, containing this:
User-agent: * Disallow: /
Now testing can commence 🙂