2016-05-30 113 views
1

我试图从一个站点重定向到另一个,如下所示。IIS URL重定向更改查询字符串参数名称

http://example.com/quickscan/?code=123456 

https://example2.com/as-quickscan/login?username=123456 

畴是不同的。重定向URL参数和URL结构也完全不同。

我试过的是以下和其他一些变化。

<rule name="Redirect quickscan" stopProcessing="true"> 
    <match url="^quickscan/\?[a-zA-Z]+=([0-9]+)?$" ignoreCase="true" /> 
    <action type="Redirect" url="https://example2.com/as-quickscan/login?username={R:1}" appendQueryString="false"/> 
</rule> 
<rule name="Redirect quickscan" stopProcessing="true"> 
    <match url="^(.*)$" ignoreCase="false" /> 
    <conditions> 
     <add input="{QUERY_STRING}" pattern="^quickscan/\?[a-zA-Z]+?=([0-9]+)?$" /> 
    </conditions> 
    <action type="Redirect" url="https://example2.com/as-quickscan/login?username={R:1}" redirectType="Permanent" appendQueryString="false" /> 
</rule> 

回答

1

这是固定的。我使用了以下内容。

<rule name="Redirect quickscan" stopProcessing="true"> 
    <match url="^quickscan/" ignoreCase="false" /> 
    <conditions> 
     <add input="{QUERY_STRING}" pattern="([a-z]+)=([0-9]+)" /> 
    </conditions> 
    <action type="Redirect" url="https://klanten.hokra.nl/staalmarkt-quickscan/login?username={C:2}" appendQueryString="false" /> 
</rule>