Play 框架将 HTTP 重定向到 https [英] Play framework redirect HTTP to https

查看:64
本文介绍了Play 框架将 HTTP 重定向到 https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 play 框架 2.2.3 版,并使用以下命令运行激活器以使用 https 访问站点.

I used play framework version 2.2.3 and I run activator using following command for accessing site using https.

./activator run  -Dhttp.port=disabled  -Dhttps.port=9043

我在浏览器中输入网址如下

and I typed URL in browser as below

https://localhost:9043/signin

然后它工作正常并重定向到 https.但问题是,当我改变我的网址如下

Then it work fine and it redirects to https. But problem is that when I changed my URL as below

http://localhost:9043/signin

那么我想将上面的URL重定向到https,这在play框架中应该如何处理?

then I want to redirect above URL to https, how should this handled in play framework?

推荐答案

从 play 2.6.x 开始,它现在由 配置

as of play 2.6.x it's now supported by a configuration

play.filters.enabled += play.filters.https.RedirectHttpsFilter

这篇关于Play 框架将 HTTP 重定向到 https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆