Print Page | Close Window

404 Trick for Directory System

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=17815
Printed Date: 29 March 2026 at 10:14am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: 404 Trick for Directory System
Posted By: angkorboy
Subject: 404 Trick for Directory System
Date Posted: 10 January 2006 at 3:24am

404 Trick for Web Promotion.

search engine's point of view. It is the biggest benefit to have well named pages. Most search engines, like Alta Vista and Yahoo.For example:
Main Category: http://www.cambodia%2dtourism.org/index.asp?cat=26 - www.cambodia-tourism.org/index.asp?cat=26 is not memorable as Main
Category: http://www.cambodia%2dtourism.org/Hospitality_Catering - www.cambodia-tourism.org/Hospitality_Catering
Sub Category: wwww.cambodia-tourism.org/Hospitality_Catering/Beverage ...etc

My directory system in table category in MsAccess:

CategoryID   | CategoryTitle      | ParentCategoryID | Description |   Pagename
26             Hospitality & Catering           0                      Hospitality_Catering
34  Berverage      26              Hospitality_Catering/Beverage

As see in index.asp :

<a href="index.asp?cat=<%=CategoryID%>"><%=CategoryTitle%></a>

But now I change it. Instead of passing the Category id with querystring, I need to get the corresponding PageName and redirect to that page. Such as:

<a href="<%=PageName%>"><%=CategoryTitle%></a>

It will now redirect to:
Category: http://www.cambodia%2dtourism.org/Hospitality_Catering - www.cambodia-tourism.org/Hospitality_Catering

Now I need to create the 404.asp page to handle all 404 page not found errors.

404.asp
<%
' Getting page name
dim PageName
PageName = Request.ServerVariables("QUERY_STRING")
%>
<%
' Category id
dim ID
set obj = Server.CreateObject("ADODB.RecordSet")
obj.Open "select CategoryID from TbleCategory where PageName = '"&PageName&"' ", DBCon
if not obj.EOF then
ID = obj.Fields("CategoryID")%>

<%
'Redirect ot Original Page
transferURL = "index.asp?cat=" + CStr(CategoryID)
Server.execute(transferURL)
%>

<%
Else
Error.asp
End if
%>


I got some problem:

ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/www.cambodia-tourism.ws/404.asp, line 10

Can anyone resolve with this problem?.




Replies:
Posted By: Scotty32
Date Posted: 10 January 2006 at 12:12pm
looks like it might be because you havent included any database connections

do you have a file like "common.asp" which has your database connection in?
if so, you need to include it

*edit*

i just noticed, you might want to use

Request.ServerVariables("SCRIPT_NAME")


since "querystring" would get

PID=96720&PN=1

from this page (edit_post_form.asp?PID=96720&PN=1)

http://www.w3schools.com/asp/coll_servervariables.asp - info here

*edit no.2*

again, you might also like to do an SQL Injection check on "PageName" to make sure your not hacked


-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net