gpt4 book ai didi

php - WP-ADMIN 重定向循环

转载 作者:行者123 更新时间:2023-12-02 20:08:09 25 4
gpt4 key购买 nike

我们有一个运行着大约 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';
}

Reference

关于php - WP-ADMIN 重定向循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com