【问题标题】:asp 301 redirect with cases not workingasp 301 重定向,案例不工作
【发布时间】:2014-01-15 09:00:55
【问题描述】:

我一直在关注丹麦 CMS 中有关 301 重定向的指南,但他们不会就此主题提供任何形式的支持。我不擅长 .asp 和我尝试过的事情,我可以想象问题会是什么。

问题是案例不起作用,所有内容都被重定向到首页,而不是我所说的特定链接。

Dim BadURLAll, BadURLPath, BadURLParam, RedirectTo
BadURLAll        = LCase(Request.ServerVariables("HTTP_URL"))
BadURLAll        = Right(BadURLAll, (Len(BadURLAll) - (Instr(BadURLAll, chr(59)))))
if LEFT(BadURLAll,7) = "http://" then
                         BadURLAll = Mid(BadURLAll, 8)
end if
Pos = Instr(BadURLAll, "/")
if Pos > 0 then
                         BadURLAll = Mid(BadURLAll,Pos)
end if
BadURLPath    = BadURLAll
Pos = Instr(BadURLAll, "?")
if Pos > 0 then
                         BadURLParam = Mid(BadURLAll,Pos)
                         BadURLPath    = Mid(BadURLAll,1, Pos-1)
end if
if Right(BadURLPath,1) = "/" then
                         BadURLPath = Mid(BadURLPath,1, LEN(BadURLPath)-1)
end if
RedirectTo = ""
SELECT CASE BadURLPath

Case "/index.php?gid=6&pid=19"      RedirectTo = "http://bodymindcompany.dk/shop/transportable-brikse-4c1.html"
Case "/index.php?gid=8&pid=19"      RedirectTo = "http://bodymindcompany.dk/shop/stationaere-brikse-166c1.html"
Case "/index.php?gid=2&pid=40"      RedirectTo = "http://bodymindcompany.dk/shop/massagestole-5c1.html"
Case "/index.php?gid=5&pid=19"      RedirectTo = "http://bodymindcompany.dk/shop/tilbehoer-til-brikse-11s.html"

END SELECT
if RedirectTo <> "" then 
                         Response.Status = "301 Moved Permanently"
                         Response.AddHeader "Location", RedirectTo
                         Response.End                                                          
else 
                         %>
                         <html>
                         <head>
                         <title>Siden blev ikke fundet / The page you are looking for has been moved</title>
                         </head>
                         <body>
                         <center>
                         <h2>Siden blev ikke fundet / The page has been moved</h2><br><br>
                         </center>
                         </body>
                         </html>
<%end if%>

有人可以带我出去吗?

最好的

克劳斯·安徒生

【问题讨论】:

    标签: redirect asp-classic


    【解决方案1】:

    根据我对您的代码的理解....

    ....如何使用这样的东西:

    Dim arrOld
    Dim arrNew
    
    arrOld = Array ("gid=1&pid=1", "gid=2&pid=2")
    arrNew = Array ("page1.asp", "page2.asp")
    
    Dim strParams, strNewPage
    
    strParams = Request.QueryString
    
    For intX = LBound (arrOld) to UBound (arrOld)
        if arrOld (intX) = strParams then
            strNewPage = arrNew (intX)
            Exit For
        End If
    Next
    
    Response.Write "strParams=" & strParams & "<br>"
    Response.Write "strNewPage=" & strNewPage & "<br>"
    

    注意:“arrOld”和“arrNew”的数组大小必须相同!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-20
      • 2013-02-06
      • 2023-03-13
      • 2013-05-16
      • 1970-01-01
      • 1970-01-01
      • 2012-11-14
      • 2013-03-01
      相关资源
      最近更新 更多