Mass 301 redirects in ASP.NET, including pages that need to redirect to a different place depending on the query string parameters(ASP.NET 中的 Mass 301 重定向,包括需要根据查询字符串参数重定向到不同位置的页面)
问题描述
我们网站的几个页面使用旧的非 SEO 友好 URL 编入索引,例如 http://www.domain.com/DocumentDetails.aspx?id=555.最近我们实现了使用存储在数据库中的 slug 的路由,并使用路由查找 slug 将您转发到正确的页面,例如:http://www.domain.com/Documents/Title-of-the-Document
We have several pages of our site indexed using old non-SEO friendly URLS such as http://www.domain.com/DocumentDetails.aspx?id=555. Recently we implemented routing that uses slugs stored in the database and looks up the slug to forward you to the right page using routing, for example: http://www.domain.com/Documents/Title-of-the-Document
这一切都很好,但是我们很难找到最好的方法来为 Google 当前索引的所有链接设置 301 永久重定向.
This is all well and good however we are having a hard time finding the best way to set up our 301 permanent redirects for all the links currently indexed by Google.
有没有办法让一个集中的地方存储旧 URL 和新 URL,并让它在找到条目时自动执行 301 重定向,并将不同的查询字符串参数视为不同的条目?我们使用的是 IIS6 和 Server 2003.
Is there a way to have 1 centralized place to store old URL and new URL, and have it do the 301 redirect automatically when it finds an entry, and also treat different query string parameters as different entries? We are using IIS6 and Server 2003.
谢谢!
推荐答案
添加一个 CustomRouteHandler 用于您的旧页面,可以对您的新 URL 执行 301:
Add a CustomRouteHandler for your old page that can do the 301 to your new URL:
//look up new url and do the 301
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/");
这篇关于ASP.NET 中的 Mass 301 重定向,包括需要根据查询字符串参数重定向到不同位置的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ASP.NET 中的 Mass 301 重定向,包括需要根据查询字


- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01