Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirection script other than error404.asp page

Status
Not open for further replies.

abovetopsecret

Programmer
Jan 16, 2008
61
GB
I have an ecommerce website that Im workign on, and my client has asked me to introduce some new stock but it needs a difefrent landing page other than the normal description page that is built into the system.

So I had this idea at first to eneter a product into the system, then once its clicked to be viewed in full it would go to a page that I built and pushed up the the root level on the server.

This is my question, I thought about using a customised error404.asp page to detect the page they looking for once they click the item, and then re-direct them to another page.

This is what i was thinking, which has come from another site.
Code:
<%
dim i, newURI, req, pageArray(1,50)

pageArray(0,0) = "long-case-mahogany.htm"
pageArray(1,0) = "Display.asp?cat=Longcase%20Mahogany&catArt=Longcase%20Mahogany"

bFound = false

for i = 0 to ubound(pageArray,2)
if pagearray(0,i) <> "" then           
    if instr(request.servervariables("QUERY_STRING"), pageArray(0,i)) <> 0 then
        req = replace(request.servervariables("QUERY_STRING"),"404;","")
          newURI = replace(req,pageArray(0,i), pageArray(1,i))
           bFound = true
     end if
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" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html>
<head>
<title>Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="robots" content="noindex,nofollow">
</head>
The page you are looking for no longer exists.
<body>
</body>
</html>

<%
   response.status = "404 Not Found"
   response.end
end if
%>

But then I realised that the page they dont want it to go too will exist as its automatically done, and so the code above will not work as the page will exist.

So is there another way around it so that I can list a load of new pages against the pages I dont want it to go to, although that page does exist.

Hope it all made sense.

Thanks
 
ah i got im going to use if, then elseif, then end if

seems to do the trick.

But its going to be a lot, so I htink I will put it all in a separate file and use an include.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top