Alex Rivera | Logout

Append Query String to IIS Rewrite Map

Asked 2011-01-16T23:03:42.463
11

I have a ReWrite Map and I would like to append any query parameters in the requested URL to the rewritten URL.

For instance:

  • /page/abc/ ---> /index.cfm?page=abc (works)
  • /page/abc/?param1=111 ---> /index.cfm?page=abc&param1=111 (doesn't work)
  • /page/abc/?param3=333&param4=444 ---> /index.cfm?page=abc&param3=333&param4=444 (doesn't work)

My web.config is:

[...]
<rules>
    <clear />
    <rule name="Rewrite rule1 for SiteMapEngine">
        <match url=".*" />
        <conditions>
            <add input="{SiteMapEngine:{REQUEST_URI}}" pattern="(.+)" />
        </conditions>
        <action type="Rewrite" url="{C:1}" appendQueryString="true" />
    </rule>
</rules>
[...]
Edit
Report

1 Answer

14

I'll be damned if I can find a reference for this, but it's my understanding that in some versions of IIS {REQUEST_URI} comes back without it's query string, and will be empty entirely if rewriting is enabled.

You should be able to use {PATH_INFO} instead.

This bug report (against Drupal!) is the issue you're describing, I think: http://drupal.org/node/298016

There's a hotfix from Microsoft, but I haven't tried it: http://support.microsoft.com/kb/954946

answered 2011-03-18T13:12:27.070

Your Answer