简体   繁体   English

使用 IIS 中的 301 parmanent 重定向规则从一个 url 重定向到另一个

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

When user hit below Url: http://example.org/buy/parts/Vehicle/3/2012/5/76/6/1013/7/Toyota/8/Corolla当用户点击以下网址时: http : //example.org/buy/parts/Vehicle/3/2012/5/76/6/1013/7/Toyota/8/Corolla
It should redirect to http://example.org/buy/parts/Vehicle/2012/Toyota/Corolla它应该重定向到http://example.org/buy/parts/Vehicle/2012/Toyota/Corolla

Application code is in C# dotnet framework 3.5 I want to redirect Url using Redirect rule or from C# code side.应用程序代码在 C# dotnet framework 3.5 我想使用重定向规则或从 C# 代码端重定向 Url。

If you just want to redirect specific URL, then you could use IIS URL rewrite module redirect rule如果您只想重定向特定的 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 https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

If you also want the URL like如果你还想要像这样的 URL

BASED on year,brand.基于年份,品牌。 You could use this rule你可以使用这个规则

   <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM