首先,我阅读 了有关此过程的许多文章。但是,由于各种原因,由于缺乏甚至是抽象的示例,或者可能过于抽象,该过程仍然难以实现或进行故障排除。还有一些“不能做”的帖子,几乎总是跟着“ 3.5,您现在可以”的告诫,因此是否可以保持模棱两可,尽管无疑是不平凡的。
摘要:
如何将wordpress多站点(WPMS)从root.com移到root / blogs?
对于此示例,我们将WPMS从“ root.com”移至“ root.com/blogs”
我了解我需要适当地更新数据库和wp-config.php中的路径。看来我可能还必须更新.htaccess?我也知道搜索/替换和mysql查询更新的序列化问题。
我有一个WPMS,我已经更新到3.5。我发现下表包含域和路径信息
移至子目录之前的现有工作配置
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. blog_id对应于wp _#_ options表,其中包含:
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.在我的wp-config.php中,有以下WPMS特定行:
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.最后,在我的.htaccess中,我有:
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]
移动网站所需的更新
在我看来,为了将网站移至/ blogs,我将:
1.将wp_blogs更新为
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.将wp_site更新为
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 );
注意:目前尚不清楚如何适当更新此步骤
5. .htaccess
我发现模糊的“适当更新.htaccess”说明,但没有具体说明。更新RewriteBase?将root.com移至root.com/blogs时,.htaccess中的哪几行会更新?
上述过程中缺少的是帖子中找到的路径。在做出更基本的更新之后,我的德鲁特人将为此使用搜索和替换工具。还是我错了?
更新 bungeshea建议,是的,我将RewriteBase指向“博客”子目录,即
RewriteBase /Blogs
最后,如果您不了解http://interconnectit.com/products/search-and-replace-for-wordpress-databases/,则应该这样做。太好了
update wp_blogs set domain=concat(domain, '/blogs'), path=concat(path, 'blogs/');
应该是update wp_blogs set path=concat('/blogs',path);