How to fix IIS rewrite to work with / or %2F in url?

Viewed 26

I use the following rules on my webserver to provide nicer urls:

<rule name="keresmind_redirect" stopProcessing="true">
  <match url="^$" />
    <conditions>
      <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
      <add input="{QUERY_STRING}" pattern="^mod=keres&amp;nyid=999&amp;keresoszo=([^=&amp;]+)$" />
    </conditions>
  <action type="Redirect" url="mind/{C:1}/" appendQueryString="false" />
</rule>
<rule name="keresmind_rewrite" stopProcessing="true">
  <match url="^mind/([^/]+)/?$" />
    <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
  <action type="Rewrite" url="?mod=keres&amp;nyid=999&amp;keresoszo={R:1}" />
</rule>

The problem is that when a user enters something with slash in "keresoszo", it gets converted to %2F like "...&keresoszo=a/c/d" becomes "/mind/a%2Fc%2Fd/" and iis gives me a 404 error because it thinks it's a different directory. I read somewhere to replace %2F to %252F in the url but I couldn't figure out how. One more thing: I have allowDoubleEscaping set to true.

Did anybody encounter the same error? Any help is really appreciated.

0 Answers
Related