Forum Moderators: open
dim textlength, LastStringURL1, LastStringURL2
textlength = Len(request.ServerVariables("SCRIPT_NAME"))
LastStringURL1 = textlength - 1
LastStringURL2 = Right(request.ServerVariables("SCRIPT_NAME"),LastStringURL1)
select case LastStringURL2
case "test"
Response.Redirect("../content/TEST/test.asp")
This is a quick snippet of some of my code. Note this doesn't support https:// but support could be added quite easily.
thePage gives you everything from the first / onwards
theError gives you the error code, in this case 404
<%
tmpError = Request.ServerVariables("query_string")
IF tmpError <> "" THEN
intLength = (InStr(1, tmpError, "http://")) - 1
theError = Left(tmpError, intLength)
tmpPage = replace(tmpError,"404;http://","")
intLength = Len(tmpPage) - (InStr(1, tmpPage, "/")) + 1
thePage = Right(tmpPage, intLength)
strSQL = "SELECT * FROM [404] WHERE [page_url] = '" & thePage & "'"
rs.Open strSQL, conn, 1, 2
IF NOT Rs.EOF THEN
page_redirect = Rs("page_redirect")
Rs("page_hit") = Rs("page_hit") + 1
Rs.update
Rs.Close
Response.Redirect(page_redirect)
ELSE
'Add Logging in here at some point
END IF
END IF %>