redirect from http to https in Jetty

别来无恙 提交于 2019-12-10 10:02:49

问题


I want make permanent redirect from http:// myurl to https:// myurl, but in Jetty I find only MovedContextHandler, with it I can redirect only context path, for examnple from myurl/bla to myurl/bla/bla

<Configure class="org.mortbay.jetty.handler.MovedContextHandler">
  <Set name="contextPath">/bla</Set>
  <Set name="newContextURL">/bla/bla</Set>
  <Set name="permanent">true</Set>
  <Set name="discardPathInfo">false</Set>
  <Set name="discardQuery">false</Set>
</Configure>

but how can I work with prefix of url?


回答1:


Best handled in your /WEB-INF/web.xml

<web-app>
  ...
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Everything in the webapp</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
</web-app>


来源:https://stackoverflow.com/questions/20611815/redirect-from-http-to-https-in-jetty

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!