Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
That worked perfectly! –  user11067 Jun 29 '09 at 20:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.