我需要一些幫助,在我的web.config中使用重定向正則表達式。我有一個網站用戶界面和一個應用程序用戶界面,它們打擊相同的服務器端API,但是我將從URL中取消調用的URL與解析API更新的未來驗證應用程序解耦。IIS Api重定向規則
這是我到目前爲止在我的web.config中,它的作用是將api.mywebsite.com重定向到mywebsite.com,但是如何編寫正則表達式來在最後添加版本,以便http://api.mywebsite.com/v1/被重定向到http://www.mywebsite.com?
<rules>
<rule name="Remove WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(api\.)(.*)$" />
</conditions>
<action type="Redirect" url="http://dev.blahblah.org.au{PATH_INFO}" redirectType="Permanent" />
</rule>
</rules>
豈不的**(*)**捕捉**/V1/**?或者我錯過了什麼? –
隨着你的設置它應該已經是這種情況。你的'url =「^(。*)$」'匹配你的'v1 /'和'input =「{HTTP_HOST}」pattern =「^(api \。)(。*)$」'匹配'api。 mywebsite.com'。 – cheesemacfly