1

I'm migrating from IIS6 with ISAPI_Rewrite to IIS7 using their Rewrite module. I have a "pretty" url that looks like this: /Shop/Q%26A. Of course that it Q&A encoded. IIS7 doesn't seem to like it. Any ideas?

I already set doubleEscaping=true because I use '+' instead of '%20' for spaces. I can't seem to find anything online about this.

2

Wow, it just so happens that Ruslan from the IIS team has been helping me with an almost identical problem over the last two days.

IIS (HTTP.sys) will parse your URL for you - for example, http://site///////dir////file serves you the same content as http://site/dir/file. It will leave the query string alone, but at this point, as we are using pretty URLs, the value is not yet in the query string!

The unencoded URL is stored in a server variable named UNENCODED_URL. You can do something like this to get that value into a capture variable:

<rule name="something" stopProcessing="true">
    <match url=".*" ignoreCase="false" />
    <conditions logicalGrouping="MatchAll">
        <add input="{URL}" negate="true" pattern="^/index\.php" ignoreCase="false" />
        <add input="{QUERY_STRING}" pattern="^$" ignoreCase="false" />
        <add input="{UNENCODED_URL}" pattern="/(.*)" />
    </conditions>
    <action type="Rewrite" url="/index.php?title={C:1}" appendQueryString="true" />
</rule>

You then map to it with a back-reference to the condition.

  • That worked perfectly! – user11067 Jun 29 '09 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy