网址重写重定向错误

时间:2017-07-19 01:32:29

标签: url-rewriting iis-8

我正在尝试使用URL Rewrite获取在IIS 8中工作的非常简单的URL重定向。我需要重写这个网址:

http://test.asystyou.com/Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/305

到此:

http://test.asystyou.com/Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/30

我已经用至少6种不同的方式写了规则,但都失败了。

第一版

<rule name="RestaurantDirect" stopProcessing="true">
  <match url="^http:\//test.asystyou.com\/Restaurant\/Made-Main-Street\/1990-Main-St-112-Sarasota,-FL-34236\/305$" />
  <conditions>
  </conditions>
  <action type="Redirect" url="http://test.asystyou.com/Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/30" appendQueryString="false" />
</rule>

第二版

<rule name="RestaurantDirect" stopProcessing="true">
  <match url="^305$" />
  <conditions>
  <add input="{HTTP_POST}" pattern="^http:\//test.asystyou.com\/Restaurant\/Made-Main-Street\/1990-Main-St-112-Sarasota,-FL-34236\/$" />
  </conditions>
  <action type="Redirect" url="http://test.asystyou.com/Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/30" appendQueryString="false" />
</rule>

第三版

<rule name="RestaurantDirect" stopProcessing="true">
  <match url="^305$" />
  <conditions>
  <add input="{HTTP_POST}" pattern="^\/Restaurant\/Made-Main-Street\/1990-Main-St-112-Sarasota,-FL-34236\/$" />
  </conditions>
  <action type="Redirect" url="/Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/30" appendQueryString="false" />
</rule>

第四版

<rule name="RestaurantDirect" stopProcessing="true">
  <match url="^305$" />
  <conditions>
  <add input="{HTTP_POST}" pattern="^http:\//test.asystyou.com\/Restaurant\/Made-Main-Street\/1990-Main-St-112-Sarasota,-FL-34236\/$" />
  </conditions>
  <action type="Redirect" url="30" appendQueryString="false" />
</rule>

第五版

<rule name="RestaurantDirect" stopProcessing="true">
  <match url="^305$" />
  <conditions>
  <add input="{HTTP_POST}" pattern="^http:\//test.asystyou.com\/Restaurant\/Made-Main-Street\/1990-Main-St-112-Sarasota,-FL-34236\/$" />
  </conditions>
  <action type="Redirect" url="{C:0}/30" appendQueryString="false" />
</rule>

第六版

<rule name="RestaurantDirect" stopProcessing="true">
  <match url="^305$" />
  <conditions>
  <add input="{HTTP_POST}" pattern="^\/Restaurant\/Made-Main-Street\/1990-Main-St-112-Sarasota,-FL-34236\/$" />
  </conditions>
  <action type="Redirect" url="{C:0}/30" appendQueryString="false" />
</rule>

其中每一个都失败了。我错过了什么?

1 个答案:

答案 0 :(得分:0)

此规则将为您解读:

<rule name="RestaurantDirect" stopProcessing="true">
    <match url="Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/305$" />
    <action type="Redirect" url="/Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/30"/>
</rule>