【问题标题】:Redirecting old asp files to new aspx (asp.net) files (Permanent Redirect, SEO)将旧的 asp 文件重定向到新的 aspx (asp.net) 文件(永久重定向、SEO)
【发布时间】:2011-03-09 07:21:40
【问题描述】:

我将我的网站从 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。

【问题讨论】:

    标签: asp.net asp-classic seo http-redirect


    【解决方案1】:

    假设您正在运行 IIS7,您可以使用 rewrite module。这允许您匹配一个 URL 并将其重定向到另一个。像 ^(.+)\.asp$ 作为模式和 {R:1}.aspx 作为重写 URL 应该这样做。

    【讨论】:

      【解决方案2】:

      您可以在 global.asa 文件中执行此操作。

      ASP 文件的 404 错误仍会调用“应用程序”。 在应用程序启动时,您可以重定向到相应的 aspx 文件。

      global.asa:

      Sub Application_OnStart
          'Get page name from request and redirect accordingly
          '...
      End Sub
      

      【讨论】:

        【解决方案3】:

        我一般把asp页面的内容替换成如下:

        <%@ Language=VBScript %>
        <%
        Response.Status = "301 Moved Permanently"
        Response.AddHeader "Location", "http://www.domain.com/index.aspx"
        Response.End
        %>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-04-19
          • 2012-07-29
          • 1970-01-01
          • 1970-01-01
          • 2012-04-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多