Click to See Complete Forum and Search --> : url typed


jrthor2
05-02-2003, 12:55 PM
I set up a custom 404 page and want to have the url that the person typed in wrong displayed on my page like this:

We're sorry, but the page you have requested (page they typed in) does not exist on this server.

How can I get the url they typed in? I currently have this:

<% function URL()
URL= "http://" & Request.serverVariables("SERVER_NAME") & _
Request.serverVariables("PATH_INFO")
End function
Response.Write(URL)
%>

But that is giving me the url of my custom 404 error page, not what they typed.

jrthor2
05-02-2003, 01:39 PM
I got it working like this:

<%
On Error Resume Next 'important in an error page to prevent another error
strTarget = Request.ServerVariables("QUERY_STRING")
strReferer = Request.ServerVariables("HTTP_REFERER")
If Len(strReferer) > 220 Then strReferer = Left(strReferer, 220)

intSemiColon = InStr(strTarget, ";") 'get the original target
If (intSemiColon > 0) And (intSemiColon < Len(strTarget)) Then
strTarget = Mid(strTarget, intSemiColon + 1)
If Len(strTarget) > 255 Then strTarget = Left(strTarget, 255)
End If

Response.Write(strTarget)
%>