如果在访问页面时尽管使用了 https,但仍重定向到 https,则原始协议不会被转发到处理响应的后端。
X-Forwarded-Proto
在通过任何代理之前,应设置一个标头以包含原始协议。Symfony 应该尊重此标头并接受请求是安全的而不是重定向(如果适当,还可以将所有链接设置为 https:// url)
您需要配置 Apache(我假设它正在终止 https 连接并拥有证书)以设置此标头以匹配原始请求协议。
看起来您可能需要信任代理,然后 Symfony 才会遵守标头Symfony Docs for proxies
// public/index.php
// ...
$request = Request::createFromGlobals();
// tell Symfony about your reverse proxy
Request::setTrustedProxies(
// the IP address (or range) of your proxy
['192.0.0.1', '10.0.0.0/8'],
// trust *all* "X-Forwarded-*" headers
Request::HEADER_X_FORWARDED_ALL
);