asp url转换函数

作者:袖梨 2022-07-02

' 函数名:RelativePath2RootPath
' 作  用:转为根路径格式
' 参  数:url ----原URL
' 返回值:转换后的URL
'================================================
Function RelativePath2RootPath(url)
 Dim sTempUrl
 sTempUrl = url
 If Left(sTempUrl, 1) = "/" Then
  RelativePath2RootPath = sTempUrl
  Exit Function
 End If

 Dim sFilePath
 sFilePath = Request.ServerVariables("SCRIPT_NAME")
 sFilePath = Left(sFilePath, InstrRev(sFilePath, "/") - 1)
 Do While Left(sTempUrl, 3) = "../"
  sTempUrl = Mid(sTempUrl, 4)
  sFilePath = Left(sFilePath, InstrRev(sFilePath, "/") - 1)
 Loop
 RelativePath2RootPath = sFilePath & "/" & sTempUrl
End Function

相关文章

精彩推荐