Symfony2 重定向到 https 路由失败(使用错误的端口) [英] Symfony2 redirect to https route fails (uses wrong port)
问题描述
我设置了 symfony,以便登录/注册是 https 路由并且工作正常.当注销时用户被重定向到登录页面时会出现问题,这里 symfony2 重定向到 https://domain.com:80/login
使用错误的端口并失败.我发现解决此问题的唯一方法是在这样的配置中放置绝对网址
I set up symfony so that login/register are https routes and work fine. The problem arises when on logout the user is redirected to the login page, here symfony2 redirects to https://domain.com:80/login
which is using the wrong port and fails. The only way I found to fix this is to place absolute urls in configuration like this
logout:
path: /logout
target: https://www.domain.com/login
但我相信一定有更好的方法来解决这个问题.
but i'm sure there must be a better way to fix this.
知道需要做什么吗?
谢谢:)
推荐答案
这种情况发生在任何重定向上,例如从不带破折号的 url 到带破折号的 url,它会重定向到正确的协议 (https),但会重定向到错误的端口(80).AFAIK 似乎 Symfony 路由依赖于 SERVER_PORT 全局而不是请求 URI 中指定的内容.所以我唯一的解决方法是在 app.php 中的 symfony2 启动之前设置它,$_SERVER['SERVER_PORT'] = 443;
hack 但现在可以使用了.
This happened on any redirect, eg from a url without dash to a url with dash, it would redirect to the correct protocol (https) but to the wrong port (80). AFAIK it seems Symfony routing relies on the SERVER_PORT global instead of what's specified in the request URI. So my only fix was to set it before symfony2 starts in app.php, $_SERVER['SERVER_PORT'] = 443;
hack but it's working now.
这篇关于Symfony2 重定向到 https 路由失败(使用错误的端口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!