leeboycymru
Programmer
I followed a thread titled ' and got out of it the code below:
<%
dim i, newURI, req, pageArray(1,50)
pageArray(0,0) = "test.htm"
pageArray(0,1) = "test.asp"
bFound = false
for i = 0 to ubound(pageArray,1)
if instr(request.servervariables("QUERY_STRING"), pageArray(0,i)) > 0 then
req = replace(request.servervariables("QUERY_STRING"),"404;","")
newURI = replace(req,pageArray(i,0), pageArray(i,1))
bFound = true
end if
if bFound then exit for
next
if bFound then
' uncomment the next line to keep the original URI but show the new content
'server.transfer("/newdir/" & pageArray(1,i))
'server.transfer(pageArray(1,i))
' uncomment the next lines to redirect to the new pagename
response.status = "301 Moved Permanently"
response.addheader "Location", newURI
response.end()
else
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html>
<head>
<title>Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
This is the 404 page
<body>
</body>
</html>
<%
response.status = "404 Not Found"
end if
%>
Im trying to do exactly the same, because i did a website and some of the .htm pages no longer exist, instead replaced by .asp pages.
So I went into my fasthosts control panel and set to that any 400, 401.. 404 etc errors go to my 404.asp error handling page.
To test this I created a page and titled it test.asp, and tested it by typing ' but nothing happened, it simply refreshed the page and stayed on the home page.
Can somebody explain to me, where I am going wrong, and if possible what i need to do.l
<%
dim i, newURI, req, pageArray(1,50)
pageArray(0,0) = "test.htm"
pageArray(0,1) = "test.asp"
bFound = false
for i = 0 to ubound(pageArray,1)
if instr(request.servervariables("QUERY_STRING"), pageArray(0,i)) > 0 then
req = replace(request.servervariables("QUERY_STRING"),"404;","")
newURI = replace(req,pageArray(i,0), pageArray(i,1))
bFound = true
end if
if bFound then exit for
next
if bFound then
' uncomment the next line to keep the original URI but show the new content
'server.transfer("/newdir/" & pageArray(1,i))
'server.transfer(pageArray(1,i))
' uncomment the next lines to redirect to the new pagename
response.status = "301 Moved Permanently"
response.addheader "Location", newURI
response.end()
else
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html>
<head>
<title>Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
This is the 404 page
<body>
</body>
</html>
<%
response.status = "404 Not Found"
end if
%>
Im trying to do exactly the same, because i did a website and some of the .htm pages no longer exist, instead replaced by .asp pages.
So I went into my fasthosts control panel and set to that any 400, 401.. 404 etc errors go to my 404.asp error handling page.
To test this I created a page and titled it test.asp, and tested it by typing ' but nothing happened, it simply refreshed the page and stayed on the home page.
Can somebody explain to me, where I am going wrong, and if possible what i need to do.l