2

我尝试使用 URL 重写 IIS 模块,以便将 url 修改为另一个 url,该参数包含在原始 url 的路径中。

Exp : 原始 URL : myurl/specialattribute_123456

想要的网址:myurl?specialattribute=123456

我使用了 URL 重写模块并在 web.config 中生成了这个标签:

<rewrite>
    <rules>
    <rule name="RedirectRule1" stopProcessing="true">
         <match url=".*/specialattribute_(.*)/" />
         <action type="Redirect" url="myurl?specialattribute={R:1}" />
                </rule>
     </rules>
     <outboundRules>
          <preConditions>
               <preCondition name="ResponseIsHtml1">
                     <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
               </preCondition>
           </preConditions>
     </outboundRules>
</rewrite>

但它没有用......有什么帮助吗?

4

3 回答 3

1

问题解决了 :

匹配标记中 url 中的内容是您网站的基本 url 之后的内容。

<match url="specialattribute_(.*)" /> <action type="Redirect" url="myurl?webserviceid={R:1}" redirectType="Temporary" />

于 2013-04-09T13:44:19.220 回答
0

试试这个:

<match url="*/specialattribute_*" />
         <action type="Redirect" url="myurl?specialattribute={R:2}" />

只需确保您在 UrlRewrite 模块规则设置中使用“通配符”即可。

于 2013-03-14T15:15:04.297 回答
0

您的问题属于您正在使用的模式。

您的规则不匹配myurl/specialattribute_123456但匹配myurl/specialattribute_123456/

如果您希望您的模式与myurl/specialattribute_123456您的示例一样匹配,请将您的规则模式更改为(只需删除尾随/):

<match url=".*/specialattribute_(.*)" />
于 2013-03-14T16:13:50.287 回答