問題描述
我們網站的幾個頁面使用舊的非 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 重定向,包括需要根據查詢字符串參數重定向到不同位置的頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!