Search code examples
angulariisurl-rewritingurl-rewrite-module

"%2b" in url does not work for url rewrite


I had following url rewrite configured in my web.config

<system.webServer>
<rewrite>
  <rules>
    <rule name="Angular Routes" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="/" />
    </rule>
  </rules>
</rewrite>
</system.webServer>

and I had this url => http://www.somesite.com/password-reset/dynamicParamValue;token=CfDJ8FDko%2FFet4BBsdmNJE1GyMyr%2FK%2Fzc8XGc788k428wh8A%2BHTxo%2BctYiPPLvhnR9KpGGxY%2By%2B9CTkLYOLk2g%2BIkYmCxVky%2FqI0cEfU5s5eKW6mNLj8J%2BJpPRXCqyMT0wNbdd%2Fczo%2FZPEuwzRpwM4ChWiQ%3D

Note: In above url I have optional angular parameter named token.

When I hit the above url in browser it gives me 404 not found. I do not have any idea why it gives me status code 404 and why url rewrite rule are not working for this particular link. Other routes are working fine. This is the only route which is not working.

If I remove % from url it does work. Why it doesn't work with %2b in the route parameter value? Please help me to get this route working.


Solution

  • HTTP Error 404.11 - Not Found

    The request filtering module is configured to deny a request that contains a double escape sequence.

    This is probably the error you have. To fix this you need to enable double escaping by adding an extra setting for the request filtering module.

    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Angular Routes" stopProcessing="true">
              <match url=".*"/>
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
              </conditions>
              <action type="Rewrite" url="/"/>
            </rule>
          </rules>
        </rewrite>
        <security>
          <requestFiltering allowDoubleEscaping="true"/>
        </security>
      </system.webServer>
    </configuration>