如何在resin4.0中将https://请求重定向到http://

时间:2012-09-13 07:18:56

标签: http https openssl web.xml resin

事实上,我得到了将http重定向到https的方法,因为我在web.xml中添加了一个过滤器。 比如,

<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>

在这种情况下,我可以在https模式下请求/xxx/*这样的网址。 还有一些像/yyy/*这样的网址必须在http模式下申请,所以我该怎么办?

1 个答案:

答案 0 :(得分:2)

在resin-web.xml中,您可以使用Resin重写标记重定向到其他URL并检查IfSecure等条件。

例如,您的WEB-INF / resin-web.xml可能看起来像

<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>

/ xxx上的第一个匹配项,并检查它是否为SSL连接。如果不是SSL连接,则会重定向到主机的https。否则,该规则将被忽略。

您/ yyy上的第二个匹配项,并检查它是否为SSL连接。如果是SSL连接,则会重定向到主机的http。否则,该规则将被忽略。

相关问题