Support » Fixing WordPress » Run two domains from same database content

  • Hi,

    I found a post form about a year ago (it is now closed) that posed the same question I have:

    I would like to have one developer environment that uses my production database. Say that our site is at Now I want to have a development site at for example http://localhost/ or I would in this case want to use the database that the site uses.

    The WP documentation has an article on this: Running a Development Copy of WordPress that says to define WP_SITEURL and WP_HOME inside of wp-config.php in the environment where the ‘home’ and ‘siteurl’ fields of the wp_options table in the database DO NOT match the location of the environment, which in my case was my localhost environment. This is to effectively overwrite the values ‘home’ and ‘siteurl’ that live in the wp_options table in the database.

    After doing this, the localhost site is able to pull all of the content from the production database, however I am not able to login. When I go to the login page and attempt to sign in, I am redirected right back to the login page. Has anyone seen this issue before or have any tips on how to resolve it.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Seems like a recipe for disaster to me.

    To make a long story short, I really doubt that WordPress was written to safely have two copies of the WordPress software running off the same database tables. There are undoubtedly some Locking mechanisms that rely on there only being one “instance” of WordPress.

    Everybody I know with a test WordPress environment clones it from the production WordPress by copying the database and WordPress files to a separate location. Personally, I want to keep my development environment as physically separate as possible from my production environment. So much so that I have it in a separate FileSpace in a separate web hosting subaccount that also prevents access from the development environment to the production database in case I forget to change a database table user ID prefix.

    Fair enough.

    In general I know this is not something most people would like to do b/c if you mess something up in the development environment, your production site is hosed. But I’m in the ‘build’ phase of a large website (it is not live yet) so this would be a nice feature.

    Thanks for the reply.

    If you really “get into” what is stored in the WordPress database, at least as I think about it now, I see some conflicts that would more or less create a corrupt WordPress environment. For example, installing a new Theme and activating it in the one environment would create a failure in the other where the Theme files don’t exist (because you didn’t install it there) yet the Theme is activated in the shared database.

    If you think about what is stored in the database versus what is stored in files. And then think about relative versus absolute URLs in the database, and it gets very confusing very quickly if you try to determine what will work and what won’t work. Images uploaded to a gallery, for example, would work in both environments if the URL in the database is absolute, but will only work in the WordPress enivironment where they were uploaded, if the URL is relative. Whether they are relative or absolute, by the way, is determined by the value of a field in the Admin panel.



    I was hoping to do this with my dev crew.
    Each has their own sub domain –, etc..
    I want to share the same content, so we don’t have to sync the db all the time (NOT FUN).

    WordPress does not cleanly separate Content and Logic, i.e. – the Database is not just Content (“Data”), so you cannot apply the I.T. principles you are used to with WordPress. I retired 4 years ago, after a Computing career that began in 1971, when Databases were first making their way out of the Lab and into the Real World. Database Integrity has always been a big issue.

    There may be a “magic bullet” solution for WordPress shared development, but I’ve never heard of one. The first one I would explore, though, is having all developers share the same subdomain, and the same WordPress Test installation, by each having a different Admin ID on that WordPress Test installation.

    The development environments I’ve seen are composed of Vanilla WordPress (fresh install with nothing in it), Vanilla Clone of Production, Clone of Production with recent Development applied to it, and Pre-Production. Other than Pre-Production, which is on a second folder on the Production web site, all others are isolated from Production (separate FileSystem and inability to communicate with the Production database) and there can be multiple copies, often personal copies for any Developer who needs it.




    For what it is worth, I ended up giving up on this. I spent a lot of hours trying to get it working with no luck. I’m stuck with dumping the production database every so often and uploading it to the development server, changing the ‘home’ and ‘siteurl’ fields inside wp_options.

    If anyone comes up with a solution I’d love to hear it.

    You talk about changing wp_options fields everytime you refresh the development database from production. To avoid this step, add a couple of lines to the wp-config.php file you use on your development environment. Start reading here for details:

    For the sake of completeness, in terms of discussing the issue, I just read about this $35 plug-in in another thread. I don’t know anything about it, but did want to mention it:

    I do something similar at work to allow several developers to shared the same database while working from individual code bases/URLs. Check out my post here:

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Run two domains from same database content’ is closed to new replies.