簡體   English   中英

使用 IIS 中的 301 parmanent 重定向規則從一個 url 重定向到另一個

[英]Redirect from one url to another using 301 parmanent redirect rule in IIS

當用戶點擊以下網址時: http : //example.org/buy/parts/Vehicle/3/2012/5/76/6/1013/7/Toyota/8/Corolla
它應該重定向到http://example.org/buy/parts/Vehicle/2012/Toyota/Corolla

應用程序代碼在 C# dotnet framework 3.5 我想使用重定向規則或從 C# 代碼端重定向 Url。

如果您只想重定向特定的 URL,那么您可以使用 IIS URL 重寫模塊重定向規則

  </rule>
                <rule name="redirect rule1" stopProcessing="true">
                    <match url="buy/parts/Vehicle/3/2012/5/76/6/1013/7/Toyota/8/Corolla" />
                    <action type="Redirect" url="buy/parts/Vehicle/2012/Toyota/Corolla" />
                </rule>

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

如果你還想要像這樣的 URL

基於年份,品牌。 你可以使用這個規則

   <rule name="redirect rule1" stopProcessing="true">
                    <match url="buy/parts/Vehicle/[^/]+/([^/]+)/[^/]+/[^/]+/[^/]+/[^/]+/[^/]+/([^/]+)/[^/]+/([^/]+)" />
                    <action type="Redirect" url="buy/parts/Vehicle/{R:1}/{R:2}/{R:3}" />
                </rule>

你能詳細說明你的問題嗎? 是ASP.NET MVC應用程序? 看到是否是-> https://docs.microsoft.com/zh-cn/aspnet/mvc/overview/older-versions-1/controllers-and-routing/asp-net-mvc-routing-overview-cs

暫無
暫無

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

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