2016-11-28 106 views
0

我有一个WordPress网站,我尝试使用SSL进行设置。该网站的工作除了管理仪表板,这将导致这个错误在Chrome:Apache mod_rewrite无限循环访问WordPress管理控制台

ERR_TOO_MANY_REDIRECTS

我发现在计算器上后,与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 

当我运行卷曲--verbose --head --location,

我看到它从http://easyofficepools.herokuapp.comhttps://easyofficepools.herokuapp.com来回重定向。我不确定http重定向来自何处。

任何想法将不胜感激!

编辑:我也注意到,从卷曲该通告的信息是HTTP和HTTPS不是:

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

回答

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';