问题描述
我们网站的几个页面使用旧的非 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 重定向,包括需要根据查询字符串参数重定向到不同位置的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!