簡體   English   中英

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

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

事實上,我得到了將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/*這樣的URL。 還有一些其他網址如/yyy/*必須在http模式下請求,所以我該怎么做?

在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。 否則,該規則將被忽略。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM