且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

路由经典ASP请求.NET - SEO重定向

更新时间:2022-12-07 08:11:54

大编辑:我指出通过@EdSF的意见,答案是错的。在怀疑我检查使用Firebug,并且,实际上,这是错误

Big edit: I was pointed by @EdSF in the comments that the answer was wrong. In disbelief I checked using Firebug, and, in fact, it was wrong.

您需要使用 Context.Response.RedirectLocation 的状态code工作。

You need to use Context.Response.RedirectLocation for the status code to work.

路由经典ASP请求.NET  -  SEO重定向

我在做同样的在Global.asax中:

I'm doing the same in global.asax:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim fullOriginalpath As String = Request.Url.ToString.ToLower

    If (fullOriginalpath.Contains("/verarticulo.asp?articuloid=")) Then
        Context.Response.StatusCode = 301
        ''// this does not work, returns a 302
        ''//Context.Response.Redirect("/noticias/" + getIDFromPath(fullOriginalpath))

        ''// this does right way
        Context.Response.RedirectLocation = "/noticias/" + getIDFromPath(fullOriginalpath)
        Context.Response.End()
    ElseIf (fullOriginalpath.Contains("/archivo.asp")) Then
        Context.Response.StatusCode = 301
        Context.Response.RedirectLocation = "/archivo/" 
        Context.Response.End()
    ElseIf (fullOriginalpath.EndsWith("/default.asp")) Then
        Context.Response.StatusCode = 301
        Context.Response.RedirectLocation = "/"
        Context.Response.End()
    End If
End Sub

你所要做的,如果你使用的是II6的唯一的事情,你必须配置该ISAPI筛选器
是这样的:

The only thing you have to do if you are using II6 you have to configure this ISAPI filter in this way:

路由经典ASP请求.NET  -  SEO重定向

该文件是 C:\\ WINDOWS \\ microsoft.net \\框架\\ V2.0.50727 \\ ASPNET_ISAPI.DLL