大众301重定向在ASP.NET,包括需要重定向到一个不同的地方根据查询字符串参数页面(Mass 3

2019-07-18 09:55发布

我们有我们的网站的几个页面使用旧的非SEO友好的URL索引如http://www.domain.com/DocumentDetails.aspx?id=555 。 最近,我们实现了一个使用存储在数据库中蛞蝓和查找蛞蝓使用路由到您转发到正确的页面,例如路由: http://www.domain.com/Documents/Title-of-the-Document

这是一切都很好但是我们有一个很难找到建立我们的301个永久重定向当前由谷歌索引的所有链接的最佳途径。

有没有办法有1米到存储旧URL和新URL集中的地方,并让它做301重定向时自动找到一个条目,也可治疗不同的查询字符串参数为不同的项目? 我们使用的是IIS6和Server 2003。

谢谢!

Answer 1:

添加CustomRouteHandler为旧页,可以做301到新网址:

//look up new url and do the 301
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/"); 


文章来源: Mass 301 redirects in ASP.NET, including pages that need to redirect to a different place depending on the query string parameters