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.
Summary:
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 "https://wordpress.stackexchange.com/"
| 2 | root.com | /matt/ |
+---------+-------------+--------+
2. wp_site
select * in wp_site;
+----+-------------+------+
| id | domain | path |
+----+-------------+------+
| 1 | root.com "https://wordpress.stackexchange.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="https://wordpress.stackexchange.com/";
define( 'DOMAIN_CURRENT_SITE', 'root.com' );
define( 'PATH_CURRENT_SITE', "https://wordpress.stackexchange.com/" );
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.
I know it’s old but I fixed it! i installed WP MU in a subfolder.
htaccess
:
RewriteEngine On
RewriteBase /YOUR_SUBFOLDER
RewriteRule ^index\.php$ - [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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule ^(.*\.php)$ YOUR_SUBFOLDER/$1 [L]
RewriteRule . index.php [L]
wp-config.php
:
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost'); // or your host
define('PATH_CURRENT_SITE', '');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
and in your database, modify this:
wp_site
domain: localhost (OR your domain but no subdirectory!)
path: /
wp_blogs
domain: localhost (OR your domain but no subdirectory in each blog_id!)
path: /
wp_sitemeta
siteurl: http://localhost/YOUR_SUBFOLDER (replace localhost with your host)