2016-01-29 47 views
0

我在Tomcat中使用urlrewite過濾器實現重定向,強制在頁面中使用https,但是我創建的規則導致重定向循環。在urlrewrite中重定向循環(Tomcat)

這是規則:

<rule match-type="wildcard"> 
    <condition type="scheme" operator="notequal">https</condition> 
    <condition name="host" operator="equal">www.example.net</condition> 
    <from>/en/page-name/</from> 
    <to type="permanent-redirect" last="true">https://www.example.net/context/en/page-name/</to> 
</rule> 

有人能幫助我嗎?非常感謝。

回答

1

您的條件:

<condition type="scheme" operator="notequal">https</condition> 
<condition name="host" operator="equal">www.example.net</condition> 
<from>/en/page-name/</from> 

意味着它不應該以https開頭,但主機應該等於www.example.net。

您重定向:

https://www.example.net/context/en/page-name/ 

以https開頭。您重定向到這個頁面,你不符合條件,重定向到這個頁面等

+0

好吧,我明白你說什麼,但我的問題是,很顯然,重定向被忽略這個條件: <條件type =「scheme」operator =「notequal」> https 我認爲,如果重定向不忽略這種情況,就不會發生循環。我不明白爲什麼要這樣做。 非常感謝您的幫助。 – kaiser1871