When moving a WP site, why does wp-admin redirect to old site?

I am in the process of moving a WP site from one host to another. I copied the database and all the files, created a new database and imported the old one. I then changed the wp-config file. The home page shows fine, but when I try to access /wp-admin it takes me back to the old site.

The new site is a dev server where I plan to make style changes before I take the site live.

What am I missing about this transition? How do I get the site to respond to the dev url correctly?


If this is a single WordPress install, there are a couple database entries with your old domain. Specifically, siteurl and home within wp_options.

That said, if the dev URL is temporary, you can also set the following two constants in wp-config.php:

define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']);
define('WP_SITEURL', WP_HOME . "https://wordpress.stackexchange.com/");

Provided that WordPress is installed in the root of your website.

Leave a Comment