我有一个WordPress网站,我正在尝试使用SSL进行设置。该网站正在运行,但管理信息中心除外,这会导致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.com和https://easyofficepools.herokuapp.com来回重定向的。我不确定http重定向的来源。
任何想法都会非常感激!
编辑:我也注意到curl的PINGBACK信息是http,而不是https:
< X-Pingback: http://easyofficepools.herokuapp.com/xmlrpc.php
X-Pingback: http://easyofficepools.herokuapp.com/xmlrpc.php
答案 0 :(得分:0)
看起来这是一个副本(唉,一个让我躲过了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';