Help migrating WPMS from subdirectory to root

I developed a WP MS project for a client. During development it was in now that the project is ready to launch I’m trying to migrate it to but I’m having a heck of time. If I edit the $path_to_current_blog in wp-config.php from ‘/staging/’ to anything else I get a “can’t connect to database message. I’ve tried editing the wp_blogs table all to no avail.

Anyone have any advice?



  • aecnu
    • WP Unicorn

    Greetings colind :slight_smile:

    this will be quite a chore and probably easier to do a complete reinstall to insure the permalinks and everything else are right.

    However, to make this happen as you have asked you will need to replace every instance of the sub domain name with the root domain name to include all instances in the configuration files and the database.

    Joe :slight_smile:

  • Timothy
    • Chief Pigeon

    Well to start with I would take a peek through the following:

    Note the difference in htaccess and wp-config.php

    I would also take a dump of the DB and run a quick find and replace on it, changing any relevant and hard coded content/links.

    You should then be set to go.

    One of the most important things here is, backup, backup, backup! :slight_smile:

    Then if you get it wrong or something happens, you have something to fall back on. :slight_smile:

    Take care.

  • colind
    • Flash Drive

    Thanks for the pointers. I’ve used iTheme’s Backupbuddy which has a clever little DB tool called RepairBuddy which makes it easy to do per-table and whole db find/replace.

    Yes, I’m familiar with the codex article. Just to clarify, the site was built as a subdirectory-style site (,, etc) So all I’m trying to do is shift the install up one level.

    Yes, I did need to edit .htaccess for the moved site; that doesn’t seem to be the issue. There’s definitely something going on with wp-config but there are only a few lines that are different from a standard WP install and only those two globals, $base and $path_to_current_blog that seem to be specific.

    I’m looking for some insight into how those to globals are used. For example, there’s the wp_sites table that holds the list of blogs in the network. That has some /staging/ strings in it. Replacing that with / breaks it.

    BTW: I’ve got everything very safely backed up and have set up a local dev environment for testing (MAMP configured to operate on port 80 with virtual hosts set up so I can have multiple web roots to try different configs)

    Thanks again for the pointers.

  • Timothy
    • Chief Pigeon

    Yeah there isn’t a great deal of differences between the variations of installs. I suppose the main difference is between single and multisite in that one uses more tables than the other.

    Backupbuddy is becoming a rather popular plugin. :slight_smile:

    Moving up a directory is usual just a task of changing paths.

    Do you have it all sorted now or are you still working on it?

  • colind
    • Flash Drive

    I’m still trying to find any MS ninjas that can help me figure out where to look. I have a sneaking suspicion that the database connection error is slightly erroneous; the DB connection parameters in wp-config are correct: a script should be able to use those settings to connect to the database. However, the problem seems to be that once connected to the db its trying to connect to the correct set of blog tables and can’t seem to do that.

    I’m a little lost about where to look next in how a MS install of WP connects to the DB and figures out what tables to use. I’m sort of guessing that the wp_sites table needs to match up with the $path_to_current_blog But I think I set that right but maybe there’s some steps after that so the scripts can correctly use the blog_0 tables.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.