Change Query String Value in IIS URL Rewrite Rule

旧巷老猫 提交于 2019-12-11 07:35:08

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/45718902/change-query-string-value-in-iis-url-rewrite-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!