2012-09-13 111 views
0

實際上,我得到了將http重定向到https的方法,因爲我在web.xml中添加了一個過濾器。如 ,如何將https://請求重定向到http://在resin4.0中

<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模式請求,那我該怎麼做?

回答

2

在resin-web.xml中,可以使用Resin rewrite標籤重定向到不同的URL並檢查IfSecure等條件。

例如,你的WEB-INF /樹脂-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。否則,該規則將被忽略。

+0

這真的是個好主意。我會有一個測試。很多... – user1667811

相關問題