Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 使用SSL的无限重定向循环_Wordpress_Apache_.htaccess_Redirect_Ssl - Fatal编程技术网

Wordpress 使用SSL的无限重定向循环

Wordpress 使用SSL的无限重定向循环,wordpress,apache,.htaccess,redirect,ssl,Wordpress,Apache,.htaccess,Redirect,Ssl,我在apache上有一个wordpress站点,位于nginx代理之后。 我已经配置了SSL,现在无法预览草稿帖子,它们最终会无限重定向到同一个url 在我们的wp配置中,我们有: define( 'FORCE_SSL_LOGIN', true ); define( 'FORCE_SSL_ADMIN', true ); if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PR

我在apache上有一个wordpress站点,位于nginx代理之后。 我已经配置了SSL,现在无法预览草稿帖子,它们最终会无限重定向到同一个url

在我们的wp配置中,我们有:

 define( 'FORCE_SSL_LOGIN', true );
 define( 'FORCE_SSL_ADMIN', true );
 if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $_SERVER['HTTPS'] = 'on';
我们拥有apache根目录的.htaccess:

RewriteEngine on 

RewriteCond %{REQUEST_URI} !^/Site/ 
RewriteCond %{REQUEST_URI} !^/phpMyAdmin/ 
RewriteRule ^(.*)$ /Site/$1 

RewriteCond %{REQUEST_URI} !^/phpMyAdmin/ 
RewriteRule ^(/)?$ /Site/index.php [L]
我们对站点文件夹具有.htaccess访问权限:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
如果我在http中访问post预览,它会工作:

但使用https,它会一次又一次地重定向到同一url:

我在wordpress index.php中添加了一个输出缓冲区,因此我可以在日志中看到,当访问安全链接时,它会生成后期预览html,因此重定向一定是在返回途中发生的,在php引擎生成后期预览之后

对于安全链接,我在apache访问日志中看到,因此我认为nginx不会导致问题:

GET/?post_type=portfolio&p=3405&preview=true HTTP/1.0 301

我们使用permalinks,所以发布的帖子在http和https中都可以预览,没有任何问题。 有什么想法吗

谢谢,
Lior提供的代码正在检查X-Forward-Proto头是否设置为https。您需要确保nginx在转发中添加了这一点,如下所示:

location / {
            proxy_set_header X-Forwarded-Proto https;
            proxy_pass http://127.0.0.1:10554;
}

我想我有一个方向——通过禁用更好的WP安全插件,我成功地用ssl预览了草案,尽管它有一些混合内容。因此,我将在插件论坛上寻找类似的问题。