【问题标题】:Apache mod_rewrite Infinite Loop when Accessing WordPress Admin Dashboard访问 WordPress 管理仪表板时的 Apache mod_rewrite 无限循环
【发布时间】:2017-04-12 18:05:43
【问题描述】:

我有一个我正在尝试使用 SSL 设置的 WordPress 网站。该站点正在运行,但管理仪表板除外,这会导致 Chrome 中出现此错误:

ERR_TOO_MANY_REDIRECTS

我在 StackOverflow 上发现了一篇有助于 HTTPS 重定向的帖子,因为 Heroku 显然做的事情有点不同。尽管如此,我仍然坚持这个错误。

我已将此添加到我的 wp-config.php 文件中,但没有成功:

define('FORCE_SSL_ADMIN', true);

我的 .htaccess 文件如下所示:

# BEGIN s2Member GZIP exclusions
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{QUERY_STRING} (^|\?|&)s2member_file_download\=.+ [OR]
    RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1
    RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END s2Member GZIP exclusions


#https://stackoverflow.com/questions/26489519/how-to-redirect-to-https-with-htaccess-on-heroku-cedar-stack/26494983#26494983
<IfModule mod_rewrite.c>
##Force SSL 
#Normal way (in case you need to deploy to NON-heroku)
RewriteCond %{HTTPS} !=on

#Heroku way
RewriteCond %{HTTP:X-Forwarded-Proto} !https 

#If neither above conditions are met, redirect to https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

当我运行 curl --verbose --head --location 时,

我看到它正在从http://easyofficepools.herokuapp.comhttps://easyofficepools.herokuapp.com 来回重定向。我不确定 http 重定向来自哪里。

任何想法都将不胜感激!

编辑:我还注意到 curl 的 PINGBACK 信息是 http,而不是 https:

< X-Pingback: http://easyofficepools.herokuapp.com/xmlrpc.php
X-Pingback: http://easyofficepools.herokuapp.com/xmlrpc.php

【问题讨论】:

    标签: wordpress apache mod-rewrite


    【解决方案1】:

    看起来这是重复的(唉,我躲了 2 个小时)!

    https://wordpress.stackexchange.com/questions/170165/wordpress-wp-admin-https-redirect-loop

    我需要将此添加到我的 wp-config.php:

    /** SSL */  
    define('FORCE_SSL_ADMIN', true);  
    // in some setups HTTP_X_FORWARDED_PROTO might contain  
    // a comma-separated list e.g. http,https  
    // so check for https existence  
    if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)  
        $_SERVER['HTTPS']='on';
    

    【讨论】:

      猜你喜欢
      • 2017-05-11
      • 1970-01-01
      • 2015-10-13
      • 2016-03-27
      • 1970-01-01
      • 2017-03-02
      • 2020-01-27
      • 1970-01-01
      • 2023-03-27
      相关资源
      最近更新 更多