Function MakeAbsolute(strLinkURL, strCurrentURL) 'Returns an absolute link URL. The strLinkURL can be 'any type, but the strCurrentURL must be absolute. Dim strCurrentFolder, strMakeAbsolute, strRoot, strDocument, strPart1, strPart2, lngDots strRoot = "" 'Initialize empty because we'll test later to see if it's been set. 'There are 3 link types: absolute, root, and relative. 'Handle the easiest case: Is strLinkURL already absolute? If Left(strLinkURL, 7) = "http://" Then MakeAbsolute = strLinkURL Exit Function End If 'Now we only have 2 remaining link types: root and relative 'There are 4 current URL types: document, CGI, folder, and root. 'Take the strCurrentURL and generate a current folder and root (both with no trailing slash) strCurrentFolder = Split(strCurrentURL, "?")(0) 'Remove any GET arguments If InStr(8, strCurrentFolder, "/") <> 0 Then 'strCurrentFolder is a document, CGI, or a folder. If Left(strLinkURL, 1) = "?" Then 'If the link starts with a question mark, then the current URL must be a CGI. Do nothing. Else 'The current URL is a document or folder. Crop to the last slash to make it a folder. strCurrentFolder = Left(strCurrentFolder, InStrRev(strCurrentFolder, "/") - 1) End If If InStr(8, strCurrentFolder, "/") = 0 Then strRoot = strCurrentFolder Else strRoot = Left(strCurrentFolder, InStr(8, strCurrentFolder, "/") - 1) End If Else 'strCurrentFolder must be a root (http://nowhere.com/). Be sure it has no trailing slash. If Right(strCurrentFolder, 1) = "/" Then strCurrentFolder = Left(strCurrentFolder, Len(strCurrentFolder) - 1) strRoot = strCurrentFolder End If End If 'Handle the next easiest link type: Is strLinkURL a root reference? If Left(strLinkURL, 1) = "/" Then MakeAbsolute = Replace(strRoot & strLinkURL, "//", "/") Exit Function End If 'Now the only link type we have is relative. Two types, unfortunately. Document and CGI If Left(strLinkURL, 1) = "?" Then 'It's a CGI. Just append it to the current URL strMakeAbsolute = strCurrentFolder & strLinkURL Else 'It's a document. Add a slash and append it to the curent URL strMakeAbsolute = strCurrentFolder & "/" & strLinkURL End If 'Remove any double dots Do While InStr(strMakeAbsolute, "/../") <> 0 'http://machine/a/b/../index.html lngDots = InStr(strMakeAbsolute, "/../") strPart1 = Left(strMakeAbsolute, lngDots - 1) 'http://machine/a/b strPart2 = Mid(strMakeAbsolute, lngDots + 3) '/index.html strPart1 = Left(strPart1, InStrRev(strPart1, "/") - 1) 'http://machine/a strMakeAbsolute = strPart1 & strPart2 'http://machine/a/index.html Loop MakeAbsolute = strMakeAbsolute End Function