Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Firstly, I've read a number of posts on this process. However, for various reasons, the process remains difficult to implement or troubleshoot for lack of even abstracted examples, or maybe too abstracted. And there's a few "can not do" posts, nearly always followed up by "with 3.5, you now can" caveats, so whether one can remains ambiguous, though no doubt non-trivial.


How to move a wordpress multisite (WPMS) from root.com to root/blogs?

For this example, we're moving a WPMS from "root.com" to "root.com/blogs"

I understand that I need to update the paths in the database and wp-config.php appropriately. It seems I may also have to update .htaccess? I'm also aware of the serialization issue with search/replace and mysql query updates.

I have a WPMS that I've updated to 3.5. I've found the following tables with domain and path info

Existing working configuration before move to subdirectory

1. wp_blogs

select blog_id, domain, path from wp_blogs;
| blog_id | domain      | path   |
|       1 | root.com    | /      |
|       2 | root.com    | /matt/ |

2. wp_site

select * in wp_site;
| id | domain      | path |
|  1 | root.com    | /    |

3. The blog_id corresponds to the wp_#_options tables which contain:

select option_name,option_value from wp_2_options 
where option_name = 'home' or option_name = 'siteurl';
| option_name | option_value             |
| home        | http://root.com/matt/    |
| siteurl     | http://root.com/matt/    |

4. In my wp-config.php I have the following WPMS-specific lines:

define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false);
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'root.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

5. Lastly, in my .htaccess, I have:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

Updates required to move the site

It seems to me that in order to move my site to the /blogs , I would:

1. Update wp_blogs to

mysql> update wp_blogs set domain=concat(domain, '/blogs'), path=concat(path, 'blogs/');
select blog_id, domain, path from wp_blogs where blog_id < 3;
| blog_id | domain      | path         |
|       1 | root.com    | /blogs/      |
|       2 | root.com    | /blogs/matt/ |

2. Update wp_site to

update wp_site set domain=concat(domain, '/blogs'), path=concat(path, 'blogs/');
select * from  wp_site;
| id | domain      | path       |
|  1 | root.com    | /blogs/    |

3. wp_#_options

| option_name | option_value                   |
| home        | http://root.com/blogs/matt/    |
| siteurl     | http://root.com/blogs/matt/    |

4. wp_config.php

define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false);
$base = '/blogs/';
define( 'DOMAIN_CURRENT_SITE', 'root.com' );
define( 'PATH_CURRENT_SITE', '/blogs/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

note: I'm not clear how this step is appropriately updated

5. .htaccess

I found vague "update .htaccess appropriately" instructions, but not specifics. Update RewriteBase? Which lines in .htaccess to I update when I move root.com to root.com/blogs?

Missing from the above process will be the paths founds in posts. My druthers are to use the search and replace tool for that, after I've made this more fundamental updates; or am I wrong?

Update bungeshea suggests that, yes, I point RewriteBase to the "blogs" subdirectory, i.e.,

RewriteBase /Blogs

Finally, if you don't know about http://interconnectit.com/products/search-and-replace-for-wordpress-databases/ you should. It's excellent.

share|improve this question
Great question, great process +1 –  kaiser Feb 10 '13 at 12:19

1 Answer 1

It looks to me as if you've solved your own problem - just follow your steps 1-4, and for step 5 update the RewriteBase in .htaccess. For updating the paths in posts, I like using the Interconnect IT sterilized search-and-replace tool.

share|improve this answer
Thanks, bungshea. As I indicate in my post, update RewriteBase to what, exactly, as per the above example? Would that be: RewriteBase /blog ? –  Screenack Jan 2 '13 at 14:05
Yes: RewriteBase /blog –  shea Jan 2 '13 at 21:41
Bungshea; done, but still not working. Still getting "Error establishing database connection" after all of the above. Worse, there's no errors thrown to my apache error log. –  Screenack Jan 4 '13 at 17:10
@Screenack what are the specifics of "Error establishing database connection"? Hint: visit wp-admin –  shea Sep 1 '13 at 6:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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