使用UrlRewriteFilter显示此网页有一个重定向循环

时间:2014-11-29 12:54:43

标签: tomcat redirect url-rewriting urlrewriter

我正在使用UrlRewriteFilterexample.com转换为www.example.com

<urlrewrite>
    <rule>
      <name>Canonical Hostnames</name>
      <condition name="host" operator="notequal">^example.com</condition>
      <condition name="host" operator="notequal">^$</condition>
      <from>^/(.*)</from>
      <to type="redirect" last="true">http://www.example.com/$1</to>
    </rule>
</urlrewrite>

当我浏览example.com浏览器时显示This webpage has a redirect loop

1 个答案:

答案 0 :(得分:0)

  

<condition name="host" operator="notequal">^example.com</condition>

将以上内容之一替换为

<condition name="host" operator="equal">^example\.com</condition>

<condition name="host" operator="notequal">^www\.example\.com</condition>