WordPress wp-admin https重定向循环
7 个回答
- 投票数
-
- 2015-02-25
您已经添加了
$_SERVER['HTTPS'] = 'on';
到您的wp-config.php ?您还应该使用 WP迁移数据库插件从
http://yoursite.com
到https://yoursite.com
You've added
$_SERVER['HTTPS'] = 'on';
to your wp-config.php?You should also use the WP Migrate DB plugin to migrate from
http://yoursite.com
tohttps://yoursite.com
-
为此,我将给您1000票!I would give you a 1000 upvotes for this!
- 10
- 2016-01-17
- Sheharyar
-
由于某些原因,通常不包括这一重要步骤.For some reason, this vital step is so often not included.
- 6
- 2016-01-27
- Tania Rascia
-
谢谢!这可能使我节省了几个小时来尝试弄清管理区域为何无法使用SSL.Thank you! That probably saved me a few more hours of trying to figure out why the admin area wasn't working with SSL.
- 5
- 2016-02-20
- Sledge Hammer
-
太好了,唯一的问题是-如果网站无法正常工作,如何安装插件:)我知道您总是应该在进行此类操作之前进行备份,但仍然如此.下面的解决方案为我工作:)that's great,the only problem is - how do you install plugin if the web-site is not working :) I know you always should backup before doing stuff like this, but still. The solution below worked for me :)
- 0
- 2016-09-22
- Timur Gafforov
-
哇! $ _SERVER ['HTTPS']='开启';救了我!wow! $_SERVER['HTTPS'] = 'on'; saved me!
- 4
- 2017-02-03
- PJunior
-
为什么这样做?我已经使用过Interconnect的S&R工具.我应该已经在数据库中使用了正确的协议.Why does this work? I already used Interconnect's S&R tool. I should already have the right protocol in the database.
- 2
- 2017-02-15
- Jeff
-
文档中的`if`语句对我不起作用,所以总是将`$ _SERVER ['HTTPS']='on';设置为总是.the `if` statement in the docs didn't work for me, so am just always setting `$_SERVER['HTTPS'] = 'on';`
- 0
- 2017-04-13
- lewis
-
在向wp-config.php添加`$ _SERVER ['HTTPS']='on';`之后,我收到消息"对不起,不允许您访问此页面."位于/wp-admin`页面,但是我以管理员身份登录.我使用Cloudflareflexible SSL,因此HTTPS流量发送到HTTP端口.After adding `$_SERVER['HTTPS']='on';` to wp-config.php, I get the message `Sorry, you are not allowed to access this page.` on `/wp-admin` page but I logged in as an admin. I use Cloudflare flexible SSL so HTTPS traffic is sent to HTTP port.
- 0
- 2017-12-21
- baptx
-
我们必须添加`if strpos($ _ SERVER ['HTTP_X_FORWARDED_PROTO'],'https')!==false){$ _SERVER ['HTTPS']='on';}`在`require_once(ABSPATH.'wp-settings.php');'之前的用法如下:https://wordpress.stackexchange.com/questions/250240/setting-serverhttps-on-prevents-access-to-wp-admin#comment414886_250254 https://wordpress.stackexchange.com/questions/262194/cannot-login-to-wordpress-admin-with-ssl-terminated-load-balancer/263461#263461We have to add `if strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) { $_SERVER['HTTPS'] = 'on'; }` before `require_once(ABSPATH . 'wp-settings.php');` like said here: https://wordpress.stackexchange.com/questions/250240/setting-serverhttps-on-prevents-access-to-wp-admin#comment414886_250254 https://wordpress.stackexchange.com/questions/262194/cannot-login-to-wordpress-admin-with-ssl-terminated-load-balancer/263461#263461
- 0
- 2017-12-21
- baptx
-
很抱歉添加另一个* $ _ SERVER ['HTTPS']='on'; *为我保存了评论,但确实确实为我解决了所有重定向问题.我尝试了书中所有nginx.conf的更改以及remove_filter('template_redirect','redirect_canonical');这有效,但仅适用于主页.$ _SERVER ['HTTPS']='on'立即修复了所有问题.谢谢!!!!Sorry to add yet another *$_SERVER['HTTPS'] = 'on';* saved me comment, but it did indeed fix all redirect issues for me as well. I tried every nginx.conf change in the book along with remove_filter('template_redirect', 'redirect_canonical'); which worked but only for the homepage. The $_SERVER['HTTPS'] = 'on' immediately fixed everything. Thank you!!!!
- 0
- 2018-03-15
- Daniel
-
这次真是万分感谢.经过2个小时的尝试其他修复后,此方法起作用.Thank you for this. This worked after 2 hours of trying other fixes.
- 0
- 2018-03-31
- hypern00b
-
+10000,让我震惊,不知道SSL为什么破坏了我的管理区域,并且网页包含URL+10000, was banging my head against a wall wondering why SSL broke my admin area and webpage include URLs
- 1
- 2018-05-17
- Wobbles
-
非常感谢!数小时的搜索终于使我找到了正确的地方.Thanks so much! Hours of search finally leads me to the right place.
- 1
- 2018-06-06
- Foxan Ng
-
谢谢!!这对于Cloudflare是必不可少的,应作为本教程的一部分.THANK YOU!! This is essential for Cloudflare and should come as part of the tutorial.
- 1
- 2018-07-05
- Sprachprofi
-
你是个天才! 非常感谢.我花了很多时间来解决这个问题. 你让我摆脱了无尽的循环. 谢谢!!You are a genius! Thank you soooooo much. I spend so many hours to figure this out. You get me out of an endless loop. Thanks!!
- 0
- 2018-07-22
- SequenceDigitale.com
-
非常感谢!$ _SERVER ['HTTPS']='开启';为我工作.Thank you so much! $_SERVER['HTTPS'] = 'on'; worked for me.
- 0
- 2018-10-20
- Komal
-
- 2016-03-16
我遇到了类似的问题,只是将以下代码段添加到了我的
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';
根据中的建议.仅在您的负载平衡器(或防火墙)设置中启用了SSL直通的情况下才需要这样做.这意味着尽管您可以在TLS/SSL中通过HTTP访问该站点,但是服务器接收的通信仅是HTTP.为了解决这个问题,需要上面的标头,以便WordPress可以将HTTPS设置为
on
配置数组中的$_SERVER
.I had a similar problem and just added the following snippet to my
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';
as suggested in the Codex. This will only be needed in case there's SSL passthrough enabled in your load balancer (or firewall) setup. Meaning that while you can access the site via HTTP within TLS/SSL, the communication that your server receives is HTTP only. To account for that, above header is needed so WordPress can "set" HTTPS to
on
in the$_SERVER
config array.-
对于使用负载均衡器的任何人来说,这都是一个很好的解决方案.我在使用Dokku(Heroku的主机自身克隆)进行托管,并且在静态资源加载和wp-admin重定向循环方面遇到了问题.Dokku还执行nginx反向代理以将传入的443通信转发到端口80,这解决了该问题.This is great solution specifically for anyone using a load balancer. I was hosting this using Dokku (a host-it-yourself clone of Heroku) and having problems with static resource loading and the wp-admin redirect loop. Dokku also does an nginx reverse proxy to forward incoming 443 traffic to port 80 and this fixes the issue.
- 2
- 2016-06-06
- ZachM
-
我只需要把`$ _SERVER ['HTTPS']='on';`放进去,因为HTTP_X_FORWARDED_PROTO甚至不在客户端服务器上的设置中:I had to just put the `$_SERVER['HTTPS'] = 'on';` because HTTP_X_FORWARDED_PROTO is not even in the settings on my client's server :|
- 3
- 2017-01-23
- Tom Roggero
-
使用AWS负载均衡器时,完美解决了我的问题.Fixed my issue perfectly when using an AWS load balancer.
- 1
- 2017-04-12
- Josh
-
这也解决了"重定向过多问题",因为我的站点位于AWS上的负载均衡器后面.This also fixed the "Too many redirect issue" as my site is behind a load balancer on AWS.
- 0
- 2017-11-01
- voam
-
对于这种情况,我认为向.htaccess文件添加修复程序很重要:https://stackoverflow.com/questions/36748110/htaccess-too-many-redirects-when-trying-to-force-https,检查@ harshal-lonare答案.I think is important to add to this answer the fix for the .htaccess file for such cases: https://stackoverflow.com/questions/36748110/htaccess-too-many-redirects-when-trying-to-force-https, check @harshal-lonare answer.
- 0
- 2018-10-05
- Gustavo Jantsch
-
- 2017-09-14
由于我还没有发表评论的权限,因此我将发布此附加内容作为另一个答案:
Elias提出的将以下内容添加到
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';
但是,只有当我将该文件中的先于其他内容使用时,它才对我有用!
As I do not have the comment privilege yet, I will post this addition as another answer:
The solution proposed by Elias, to add the following to
wp-config.php
, did the trick for me:/** 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';
However, it only worked for me when I put it before everything else in this file!
-
这正是我的问题所在.我把这些放在文件的末尾,它没有用.我准备从头开始重建我的网站.将它们移至顶部和底部,已修复问题.谢谢谢谢!!This was exactly what my problem was. I had put these at the end of the file and it wasn't working. I was ready to rebuild my site from scratch. Moved them to the top and bam, issue fixed. Thank you, Thank you!!
- 1
- 2018-02-03
- Dean Poulin
-
如果您在Cloudflare之类的代理DNS之后使用灵活的SSL,则此解决方案非常有用.谢谢.This solution is great if you're using a flexible SSL behind a proxy DNS like Cloudflare. Thank you.
- 0
- 2018-02-16
- Stefan P
-
确认工作.非常感谢您,它解决了API和IFrame遇到的许多问题.该网站未启用HTTPS,但是我们需要一些页面才能启用它.WordPress默认应将此设置为...Confirmed working. Thank you so much, this fixes a lot of problems we had with API's and IFrames. The site doesn't have HTTPS enabled, but we need some pages to have it on. Wordpress should have this as a setting by default...
- 0
- 2018-04-25
- Andy
-
仅供参考-该代码可以在任何位置,但必须在文件末尾的`require_once(ABSPATH.'wp-settings.php');`之前.FYI - that code can be anywhere but needs to be before `require_once( ABSPATH . 'wp-settings.php' );` which is at the end of the file.
- 0
- 2019-09-20
- Damodar Bashyal
-
这行得通,谢谢This works, thanks
- 0
- 2020-04-28
- Mohammed Tawfik
-
这也对我有用this works for me as well
- 0
- 2020-06-10
- Md. Amanur Rahman
-
- 2017-02-21
这本书的另一个版本,只需将其添加到wp-config.php顶部
原因是可能存在负载平衡器或某些未传递正确的https值的东西,因此您必须从其他地方获取它并将其伪造为wordpress.
if ( (isset($_SERVER['HTTP_X_FORWARDED_PORT'] ) && ( '443' == $_SERVER['HTTP_X_FORWARDED_PORT'] )) || (isset($_SERVER['HTTP_CF_VISITOR']) && $_SERVER['HTTP_CF_VISITOR'] == '{"scheme":"https"}')) { $_SERVER['HTTPS'] = 'on'; }
Another version for the books, just add this to the top of wp-config.php
Reason is that there could be load balancers or something that does not pass along the proper https value, so you have to grab it from elsewhere and fake it for wordpress.
if ( (isset($_SERVER['HTTP_X_FORWARDED_PORT'] ) && ( '443' == $_SERVER['HTTP_X_FORWARDED_PORT'] )) || (isset($_SERVER['HTTP_CF_VISITOR']) && $_SERVER['HTTP_CF_VISITOR'] == '{"scheme":"https"}')) { $_SERVER['HTTPS'] = 'on'; }
-
- 2019-02-10
实际上...我遇到了这个问题,解决起来非常容易且令人尴尬.不知何故,在webhost上我的wp-admin文件夹被删除,因此没有wp-admin出现此相同的错误消息.
经过数小时的测试,我看到了许多不同的方式,然后再次下载并上传后,一切正常.
检查一下,就这么简单.
Actually... I had this issue and the solving was quite easy and embarassing. Somehow on the webhost my wp-admin folder was deleted and therefore no wp-admin with this same error message.
After hours of testing so many different ways I just saw this and when downloaded and uploaded again it all worked as normal.
Check it guys, it can be that simple.
-
- 2019-07-19
5岁的问题...
好的,安装了SSL证书并使用找到的
http链接更改为 https
后,出现了此错误. " https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar" rel="nofollownoreferrer">此处.我尝试了各种配置,除非我进行了以下设置,否则似乎都无法解决此问题:
define('FORCE_SSL_ADMIN', true); define('FORCE_SSL_LOGIN', true);
对此:
define('FORCE_SSL_ADMIN', false); define('FORCE_SSL_LOGIN', false);
它允许我访问登录页面,但随后无法实际登录.我尝试回答了两个,但不幸的是,它还是没有帮助,直到我做了以下更改:
/** 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') !== true) $_SERVER['HTTPS']='on';
由于某种原因,我不知道为什么-我不得不更改
!== 错误
到
!== 是
我将nginx作为主机运行,并反向代理到nginx单元... 如果有人知道为什么这样做,请告诉我
5 year old Question...
Okay, I had this error, after installing my SSL Certificate and changing all links that were
http
tohttps
using the wp-cli.phar found here.I tried various configurations and none seemed to resolve this, unless I set this:
define('FORCE_SSL_ADMIN', true); define('FORCE_SSL_LOGIN', true);
to this:
define('FORCE_SSL_ADMIN', false); define('FORCE_SSL_LOGIN', false);
It allowed me to hit the log-in page, but then was unable to actually log-in. I tried answer two but that unfortunately didn't help either, Untill I did the following change:
/** 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') !== true) $_SERVER['HTTPS']='on';
For some reason, I do not know why - I had to change the
!== false
to
!== true
I'm running nginx as host and reverse proxy to nginx unit... If anyone has any idea why that worked, Please let me know
-
哦,为了F @!$,谢谢!2020年,我们仍然必须爬网才能将SSL放在wordpress上,这是因为,以某种方式,最给定的答案对无效的语句无效. 再次感谢!Oh for F@!$'s sake, Thank you! 2020, and we still have to crawl the web to be able to put SSL on wordpress, and it's because, somehow, the most given answer doesn't work for an invalid statement. Thanks again!
- 0
- 2020-08-15
- EmmanuelBeziat
-
- 2020-05-07
将网站托管在Azure webapp服务Linux上时,我遇到了同样的问题.
尝试使用此插件.激活时请多加注意. https://wordpress.org/plugins/jsm-force-ssl/
此插件使用本地WordPress过滤器,而不是PHP的输出 缓冲区,以实现最大的可靠性,性能和缓存兼容性 (此插件不会影响缓存性能),以及301 永久重定向以获得最佳SEO(301重定向被认为是最佳 从HTTP转换为HTTPS时,用于SEO).
大型主机的荣誉代理/负载平衡变量 环境:
HTTP_X_FORWARDED_PROTO HTTP_X_FORWARDED_SSL要求:
您的Web服务器必须配置有SSL证书,并且能够 处理HTTPS请求.
只需激活插件即可完成
没有插件设置可调整,也没有更改 您的WordPress配置-只需激活或停用 用于启用/禁用过滤器和动态重定向的插件.
I had the same issue when I hosted my site on Azure webapp service Linux.
Try this plugin. take care when it active it works. https://wordpress.org/plugins/jsm-force-ssl/
This plugin uses native WordPress filters, instead of PHP’s output buffer, for maximum reliability, performance and caching compatibility (this plugin does not affect caching performance), along with 301 permanent redirects for best SEO (301 redirects are considered best for SEO when moving from HTTP to HTTPS).
Honors proxy / load-balancing variables for large hosting environments:
HTTP_X_FORWARDED_PROTO HTTP_X_FORWARDED_SSL Requirements:
Your web server must be configured with an SSL certificate and able to handle HTTPS request.
Simply activate the plugin and you’re done:
There are no plugin settings to adjust, and no changes are made to your WordPress configuration — simply activate or deactivate the plugin to enable / disable the filters and dynamic redirects.
我正在使用nginx作为我的Web服务器,并且我已经编辑了配置文件以指向https,因此我将WordPress网址设置更改为https,并且还将WordPressforce ssl管理员代码添加到了我的wp-config文件中,但是我一直在运行出现错误" 此网页具有重定向循环"