2014-01-15 67 views
0

我一直在關注丹麥CMS有關301重定向的指南,但他們不會對此主題提供任何形式的支持。我不擅長.asp,我嘗試過的東西,我可以想象問題是。asp 301重定向不起作用的案件

問題是,案件不工作,一切都只是重定向到首頁,而不是我說的具體鏈接。

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%> 

任何人都可以讓我出去嗎?

最佳

克勞斯·安德森

回答

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」的數組大小必須相同!