我将网站从 asp 升级到 asp.net。 这意味着我以前的所有 asp 文件都已过时。 我不想失去旧页面的 Google 排名。
重定向的正确方法是什么? 我试图捕捉所有旧的 asp 页面是我的 404,然后:
if Request.QueryString("aspxerrorpath").contains("index.asp") = true then
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", "http://www.domain.com/index.aspx")
Response.Redirect("/index.aspx")
end if
但它不捕捉 asp 页面,只捕捉 aspx。
最佳答案
假设您正在运行 IIS7,有一个 rewrite module可用的,你可以使用。这允许您匹配一个 URL 并将其重定向到另一个 URL。像 ^(.+)\.asp$
作为模式和 {R:1}.aspx
作为重写 URL 应该可以做到。
关于asp.net - 将旧的 asp 文件重定向到新的 aspx (asp.net) 文件(永久重定向,SEO),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3135469/