Muhammad Zeeshan Tahir
Muhammad Zeeshan Tahir

Reputation: 442

Change Query String Value in IIS URL Rewrite Rule

I have tried multiple combinations so far but no luck. I have a URL like below.

https://teams.company.com/Search/pages/results.aspx?url=https://teams2017.company.com/sites/hrdepartment

I want to create a rule that will change the query string value from teams2017 to teams only, like below.

 https://teams.company.com/Search/pages/results.aspx?url=https://teams.company.com/sites/hrdepartment

I am using IIS 8.5 with IIS Rewrite rule installed.

Upvotes: 3

Views: 4415

Answers (1)

Victor Leontyev
Victor Leontyev

Reputation: 8736

You rule should be like that:

<rule name="teams2017 to teams" stopProcessing="true">
    <match url="^Search/pages/results.aspx$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="(.*)teams2017(\.company\.com.*)" />
    </conditions>
    <action type="Redirect" url="{R:0}?{C:1}teams{C:2}" appendQueryString="false" />
</rule>

Upvotes: 5

Related Questions