0
我在Tomcat服務器上遇到了一些問題:我試圖將所有請求從裸域重定向到以www開頭的所有請求。 谷歌搜索和使用urlReWriteFilter的指導給了我相反的方向一些海洋觀測系統的例子(從裸域到www):Tomcat:如何將www子域重定向到裸體
<rule>
<note>
Moves all annoying www requests to the naked domain
</note>
<name>Domain Name Check</name>
<condition name="host" operator="notequal">www.maternal-beauty.co.il</condition>
<from>^(.*)$</from>
<to type="permanent-redirect">http://www.maternal-beauty.co.il$1</to>
</rule>
的問題是,當我只是刪除了「www'prefix,我沒有重定向。我請求的每個地址只是返回了corespomding頁面而沒有任何重定向。
<rule>
<note>
Moves all annoying www requests to the naked domain
</note>
<name>Domain Name Check</name>
<condition name="host" operator="notequal">maternal-beauty.co.il</condition>
<from>^(.*)$</from>
<to type="permanent-redirect">http://maternal-beauty.co.il$1</to>
</rule>
請注意,唯一的區別是我從condition元素和to元素中刪除了'www'prefix。 我無法弄清楚這裏有什麼問題。 如果它很重要,我使用的是Tomcat 7.0.34,當然還有org.tuckey.web.filters.urlrewrite.UrlRewriteFilter過濾器。
感謝您的回覆,
蓋伊