WordPress: How to change site URL and disallow robots

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:



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:

Now testing can commence 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.