tomcathttp-redirecturl-rewritingurlrewriter

using UrlRewriteFilter shows This webpage has a redirect loop


I am using UrlRewriteFilter to convert example.com to 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>

When i browse example.com browser shows This webpage has a redirect loop


Solution

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

    Replace the above with one of the following

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

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