情况不起作用的asp 301重定向

时间:2014-01-15 09:00:55

标签: redirect asp-classic

我一直在丹麦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%>

有人可以帮助我吗?

最佳

Klaus Andersen

1 个答案:

答案 0 :(得分:0)

从我对你的代码中的理解......

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

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”的数组大小必须相同!