%
dim pageRequested, pageErrorNum, missingURL, newURL, DebugMode, BaseURL, defaultURL, redirectURL
dim URLarray 'as array
BaseURL="www.affinia.com"
defaultURL="/"
debugMode=false
'Have we been here before with the same file name/URL?
'refering URL should tell us and if it is the same as the one we have, let's send to home page.
with request
if isempty(.queryString) or .queryString="" then
pageRequested = "http://" & BaseURL & "/!404" 'someone trying to access this script directly
pageErrorNum = ""
else
pageRequested = mid(.queryString, instr(.queryString,";") + 1)
pageErrorNum = left(mid(.queryString, instr(.queryString,";") - 3),3)
end if
end with
'bulid array based on the /'s
URLarray=split(pageRequested, "/")
'missingURL=URLarray(ubound(URLarray))
CleanString = URLarray(0) & "/" & URLarray(1) & "/" & URLarray(2) & "/"
'response.write "
" & CleanString & "
"
'remove the http://somedomain/
missingURL=replace(pageRequested,CleanString,"")
'strip off any URL variables. if there is a ? strip off it and everything after
'cleans off page_name.cfm?thisURL=sampleval...
URLarray=split(missingURL, "?")
missingURL=URLarray(0)
newURL=GetNewURL(missingURL)
if newURL="!404" then newURL=defaultURL
'CHeck for existence of file!!!!
If FileExist(server.MapPath(newURL)) Then redirectURL = BaseURL & newURL else redirectURL = BaseURL & defaultURL
if DebugMode then
response.write "a00_404
| OLD | NEW |
| " & missingURL & " | " & newURL & " |