1
我想知道應該使用URL重寫在IIS 8中工作的非常簡單的URL重定向。我需要重寫這個URL: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是最接近這個的。是什麼導致這種情況不起作用?是否因爲我包含域名而不需要它?或者它與我如何逃避特殊字符有關?也許如果我能理解我錯在哪裏,我可以更有效地向前邁進。 – gacto
URL重寫將'match url'中的模式與請求路徑進行比較,而不用啓動斜槓。在你的情況下,請求路徑是「餐館/製造主街/ 1990-Main-St-112-Sarasota,-FL-34236/305」。並且你從#1#http:\ // test.asystyou.com \/Restaurant \/Made-Main-Street \/1990-Main-St-112-Sarasota,-FL-34236 \/305 $' '沒有匹配這串'Restaurant/Made-Main-Street/1990-Main-St-112-Sarasota,-FL-34236/305' –
沒問題。感謝解決方案和解釋。 – gacto