本文介绍了如何在resin4.0中将https://请求重定向到http://的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

事实上,当我在web.xml中添加过滤器时,我得到了将http重定向到https的方法.例如

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>

在这种情况下,我可以将类似/xxx/*的网址设置为以https模式进行请求.还有一些其他网址,例如/yyy/*,必须在http模式下进行请求,所以我该怎么做?

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 ?

推荐答案

在resin-web.xml中,您可以使用Resin重写标签重定向到其他URL并检查诸如IfSecure之类的条件.

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

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

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>

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

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.

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

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.

这篇关于如何在resin4.0中将https://请求重定向到http://的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 00:32