[英]IIS Api redirect rule
我在web.config中需要有關重定向正則表達式的幫助。 我有一個網站用戶界面和一個應用程序用戶界面,它們使用相同的服務器端API,但我正在將兩者中調用的網址分離,以便將來針對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>
<rule name="Remove WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(api\.)(.*)$" />
<add input="{PATH_INFO}" pattern="^/v(\d+)/(.*)$" />
</conditions>
<action type="Redirect" url="http://localhost{PATH_INFO}?v={C:1}" redirectType="Permanent" />
</rule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.