URL Rewrite with Query String

让人想犯罪 __ 提交于 2019-12-13 05:35:56

问题


I am writing a rewrite rule in IIS with type Redirect. I want the new url to have a query string parameter value added newly to it. The old url does not have any query string values.

What is the best way to achieve this?

Old url: abc.com/2017/Sample-Page

New Url: test.abc.com/2017/Sample-Page?redirect=y

<rule name="rewrite with query string" stopProcessing="true">
    <match url="(.*)2017/Sample-Page(.*)" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="abc.com" />
    </conditions>
    <action type="Rewrite" url="http://test.abc.com/{R:0}?redirect=y"/>
  </rule>

回答1:


This worked:

<rule name="rewrite with query string" stopProcessing="true">
    <match url="(.*)2017/Sample-Page(.*)" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="abc.com" />
    </conditions>
    <action type="Rewrite" url="http://test.abc.com/{R:0}?redirect=y"/>
  </rule>


来源:https://stackoverflow.com/questions/33655211/url-rewrite-with-query-string

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