ASP.NET 中的大量 301 重定向,包括需要根据查询字符串参数重定向到不同位置的页面 [英] Mass 301 redirects in ASP.NET, including pages that need to redirect to a different place depending on the query string parameters

查看:21
本文介绍了ASP.NET 中的大量 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 中的大量 301 重定向,包括需要根据查询字符串参数重定向到不同位置的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆