簡體   English   中英

IIS URL重寫刪除部分路徑

[英]IIS URL Rewrite remove part of path

在研究了網址重寫並查看了許多帖子之后,我仍然對為什么我的網址重寫無法正常工作感到困惑。 我正在嘗試從路徑中刪除/carrot/

例如: https://my.server.com/carrot/mobile/pathhttps://my.server.com/carrot/mobile/path

應該成為: https://my.server.com/mobile/path : https://my.server.com/mobile/path

我的URL重寫規則非常簡單,如下所示:

    <rule name="RemoveCarrotFromPath">
      <match url=".*carrot(.*)" />
      <action type="Rewrite" url="{R:1}" />
    </rule>

感謝所有幫助。

在下面編輯,您可以找到所有正在使用的規則,以防萬一這是各種規則沖突的問題:

<rewrite>
  <rules>
    <rule name="redirectPayment" stopProcessing="true">
      <match url="/payment" />
      <action type="Redirect" url="https://my.app.com/carrot/Payment" />
    </rule>
    <rule name="redirectMembership" stopProcessing="true">
      <match url="/membership" />
      <action type="Redirect" url="https://my.app.com/carrot/Membership" />
    </rule>
    <rule name="RemoveCarrotFromPath">
      <match url=".*carrot(.*)" />
      <action type="Rewrite" url="{R:1}" />
    </rule>
  </rules>
</rewrite>

解決我的問題的方法是使用Redirect而不是Rewrite ,如下所示:

<rule name="RemoveCarrotFromPath">
  <match url=".*carrot(.*)" />
  <action type="Redirect" url="{R:1}" />
</rule> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM