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?

5 Answers 5


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 . '/');

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


It is not a big problem. Your Database contains all previous links which cannot be automatically converted. There are two type of solutions for that:

  1. In wp-config.php add this code:

    define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']);
    define('WP_SITEURL', WP_HOME . '/');
  2. Change the following SQL by replacing "oldurl" with the previous link and "newurl" with the current link:

UPDATE wp_posts SET guid = replace(guid, 'oldurl','newUrl'); 

UPDATE wp_posts SET post_content = replace(post_content, 'oldurl', 'newUrl'); 

UPDATE wp_links SET link_url = replace(link_url, 'oldurl', 'newUrl'); 

UPDATE wp_links SET link_image = replace(link_image, 'oldurl', 'newUrl'); 

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'oldurl', 'newUrl'); 

UPDATE wp_usermeta SET meta_value = replace(meta_value, 'oldurl', 'newUrl'); 

UPDATE wp_options SET option_value = replace(option_value, 'oldurl', 'newUrl') WHERE option_name = 'home' OR option_name = 'siteurl';

Run these SQL queries in your database, changing the prefix if you have something different than wp_.


Just changing the site URL in the config will likely not update all of the internals to create a working dev site for you (unless the site is pretty bare-bones). You'll have problems with serialized data not showing and links within posts pointing to the old site.

It would be smarter to use a migration tool like Backup Buddy or Duplicator to create a complete copy of the site that can be re-deployed at a new location with a new URL. Doing this, you'll still have working links within posts, any custom menu links, etc. Using one of these will make launching your changes simpler as well. Just package it all up and re-deploy to your production site when you're finished.

If you don't want to spend the time downloading/uploading everything again, you can just migrate the database using something like WP Migrate DB. Install it on your production site, export a database with the new URL and import the migrated database to your dev via phpMyAdmin or similar. Any hard-coded links in your theme will still need to be updated and your .htaccess will need to be updated if you're installing in a sub-folder.

Change the RewriteBase line to:

RewriteBase /yourfolder/

And the line that redirects to your index.php to:

RewriteRule . /yourfolder/index.php [L]
  1. phpMyAdmin: go to wp_options table set homeurl and siteurl as your new url
  2. Login to you wp-admin dashboard go to setting->general change WordPress Address (URL) and Site Address (URL)

You have to change the Site address (URL) and WordPress address (URI) through admin panel before moving the site to another URL.

In your case you can't do that to a live site, so you can try a tool like Search and replace databases to change the URL from the dev site database.

You can also reference Moving WordPress

Not the answer you're looking for? Browse other questions tagged or ask your own question.