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过滤器。
感谢您的回复,
盖伊