我们有一个运行着大约 6 个站点的多站点。
我们的 3 个网站可以通过 wp-admin 访问,其他 3 个则不能。
浏览器告诉我们正在进行太多重定向。这只有在我们登录 wp-admin 后才会发生。 wp-login 页面工作正常。
我们之前遇到过这个问题,通过在 wp-config
中进行以下修复解决了目前正在运行的 3 个站点:
$_SERVER['HTTPS'] = 'on';
前端也工作得很好,只是 wp-admin 有问题。
背景信息:
服务器:Nginx + Apache。从 Nginx 开始,然后重定向到 Apache
SSL:已启用
最佳答案
根据法典:
If WordPress is hosted behind a reverse proxy that provides SSL, but is hosted itself without SSL, these options will initially send any requests into an infinite redirect loop. To avoid this, you may configure WordPress to recognize the HTTP_X_FORWARDED_PROTO header (assuming you have properly configured the reverse proxy to set that header).
以下操作将解决该问题。
将其添加到 wp-config.php。 (codex reference)
/* SSL Settings */
define('FORCE_SSL_ADMIN', true);
/* Turn HTTPS 'on' if HTTP_X_FORWARDED_PROTO matches 'https' */
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
$_SERVER['HTTPS'] = 'on';
}
关于php - WP-ADMIN 重定向循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200976/