如何修复多站点的仪表板子目录站点链接?



我们有一个多站点bitnami子目录安装。每个子目录都是特定于国家/地区的站点,因此https://example.com根站点并https://example.com/[country code]子目录 在开发 http://[ip]的过程中,没有出现任何问题。在移动到我们的域并为每个站点添加编辑器后,我们开始遇到一个非常具体的问题。

首先是细节:

.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
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 . index.php [L]
</IfModule>
# END WordPress

WP-配置.php

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', '[redacted].com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
define( 'WP_HOME', 'https://[redacted].com' );
define( 'WP_SITEURL', 'https://[redacted].com' );
define( 'WP_2_HOME', 'https://[redacted].com/da' );
define( 'WP_2_SITEURL', 'https://[redacted].com/da' );
define( 'WP_3_HOME', 'https://[redacted].com/de' );
define( 'WP_3_SITEURL', 'https://[redacted].com/de' );
define( 'WP_4_HOME', 'https://[redacted].com/se' );
define( 'WP_4_SITEURL', 'https://[redacted].com/se' );
define('FS_METHOD', 'direct');

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
define( 'SUNRISE', 'on' );
require_once(ABSPATH . 'wp-settings.php');
define('WP_TEMP_DIR', '/opt/bitnami/apps/wordpress/tmp');

问题所在

每个站点的wp_[id]_options表中的option_values时不时地更改。 例如select * from wp_2_options where option_name = 'siteurl';option_value将更改为根 url 而不是根 url + 子目录(即https://example.com/而不是https://example.com/[subdirecotry])。结果是仪表板中的管理链接排除了 url 中的子目录。这可能会导致 404,因为根目录中不存在帖子 ID,管理员只能通过在 url 栏中手动输入子目录来访问特定于站点的仪表板,对帖子的更改(页面、博客文章、模板等已从根目录复制并因此共享帖子 ID)保存到根目录而不是子目录等。

用户端没有任何中断。网站本身的所有链接都很好。

每当我们遇到这种情况或报告时,我们都必须手动将相应wp_[id]_options表中的option_value更改回根 url + 子目录并回滚到较早的发布修订版。至少可以说这很烦人。

起初,我们认为这是一个与域移动相关的问题,但直到我们开始添加管理员、编辑、SEO 经理等,我们才开始遇到这个问题。然后我们想,如果用户在不同的站点上拥有角色,那么当他们进行身份验证时,它就会中断,但消除该变量并不能阻止问题再次发生。

使用一个名为 Duplicator 的插件

或者,您必须更新数据库上的site_url链接,然后导航到WP Settins->Permalinks,然后单击更新以重写htaccess文件。

最新更新