playframeworkplayframework-2.3

Play framework redirect HTTP to 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

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

http://localhost:9043/signin

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


Solution

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

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