Search code examples
url-rewritingsharepoint-2010iis-7.5

Rewrite a URL with curly brackets around a query string value in IIS


How can I replace the query string value of my URL using IIS? All I want to do is change the value in the ListId from the old value to the new one.

Old ListId value: 7898D8D3-7FDC-427C-B81D-AE95ADA03F07

New ListId value: 32992B8E-905E-47CA-BAB2-846D3E5D399F

Source URL:

/sites/techopskb/_layouts/listform.aspx?PageType=4&ListId={7898D8D3-7FDC-427C-B81D-AE95ADA03F07}&ID=5859&ContentTypeID=0x0100D98D0B04DDCDF84C872D58FFE6AA6B84

Target URL:

/sites/techopskb/_layouts/listform.aspx?PageType=4&ListId={32992B8E-905E-47CA-BAB2-846D3E5D399F}&ID=7537&ContentTypeID=0x0100D98D0B04DDCDF84C872D58FFE6AA6B84

The curly braces are causing my headaches. I've tried the %7B and %7D in the expression, but IIS doesn't like it. (BTW- this is a SharePoint 2010 website, IIS v7.5)

Thanks.


Solution

  • You need to use {UrlDecode:%7B} . See here

    So your rewrite rule will look something like below

    <rule name="ModifyQueryString" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
            <add input="{QUERY_STRING}" pattern="(.*)listid=\{7898D8D3-7FDC-427C-B81D-AE95ADA03F07\}(.*)" />
        </conditions>
        <action type="Redirect" url="http://example.com/sites/techopskb/_layouts/listform.aspx?{C:1}&amp;listid={UrlDecode:%7B}32992B8E-905E-47CA-BAB2-846D3E5D399F{UrlDecode:%7D}{C:2}" appendQueryString="false" />
    </rule>