How do I redirect https:// requests to http:// in resin4.0

℡╲_俬逩灬. 提交于 2019-12-23 04:45:09

问题


in fact, i got the method for redirect http to https ,as I add a filter in web.xml. such as,

<security-constraint>
    <web-resource-collection>
        <web-resource-name>SSL</web-resource-name>
        <url-pattern>/xxx/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

in this case, I can make the urls like /xxx/* to be requested in https mode. There are some others urls like /yyy/* which must be requested in http mode, so how can I do that ?


回答1:


In the resin-web.xml, you can use the Resin rewrite tags to redirect to a different URL and check for conditions like IfSecure.

For example, your WEB-INF/resin-web.xml might look like

<web-app xmlns="http://caucho.com/ns/resin"
         xmlns:resin="urn:java:com.caucho.resin">

  <resin:Redirect regexp="^/xxx/" target="https://myhost.com/xxx/">
    <resin:IfSecure value="false"/>
  </resin:Redirect>

  <resin:Redirect regexp="^/yyy/" target="http://myhost.com/yyy/">
    <resin:IfSecure value="true"/>
  </resin:Redirect>

</web-app>

The first matches on your /xxx, and checks if it's an SSL connection. If isn't an SSL connection, it redirects to the https for the host. Otherwise the rule is ignored.

The second matches on your /yyy, and checks if it's an SSL connection. If it is an SSL connection, it redirects to the http for your host. Otherwise the rule is ignored.



来源:https://stackoverflow.com/questions/12401292/how-do-i-redirect-https-requests-to-http-in-resin4-0

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