View Full Version : ASP directory resolving!

08-08-2004, 02:11 PM
Hi there,

I was just wondering, how I can solve this problem.

I have got a site with thousands of members with their own profile, now what I want is that obviously has got their own link,


this then should resolve into www.mydomain.com/member.asp?id=124 or whatever number,

now i know there is a way to do this, to create all member folders and have an index page in there that redirects to the members.asp, but the reason I want to do it this way is that I don't want to have 5000 folders on my server.

Now my question is, how can i resolve a folder name into a filename + id... without having this folder,...


Roy Sinclair
08-09-2004, 05:53 PM
Write a custom 404 Error page, which can still display the ordinary 404 error message when a regular error occurs but can redirect the user to the appropriate page when it's one of these pseudo pages.

08-11-2004, 10:53 AM
Thanks for your help. I think I got the idea.

The only question I have got is, how do I actually read what the user typed into the URL bar.

Let's say he typed in www.mydomain.com/membername, how can I read out membername and then redirect the page.

Thanks for your help again.

Roy Sinclair
08-11-2004, 11:16 PM
Here's some of the code from my custom 404 Error page which should help get you started:

Dim ServerName ' HTTP server name
Dim PageInErrorHTTP ' Full URL to the page with the error
Dim PageInErrorRel ' Relative URL to the page with the error
Dim PageInErrorResolved ' Full Local path name of the page with the error
Dim UrlInErrorHTTP ' Full URL to the missing file
Dim UrlInErrorRel ' Relative URL to the missing file
Dim UrlInErrorResolved ' Full local path name of the missing file
Dim InServer ' Flag to speed processing when not user visible item
Dim T ' Temporary variable

on error resume next ' Don't comment out, this page needs error checking enabled!

InServer = 0
ServerName = Request.ServerVariables("HTTP_HOST")
If Request.ServerVariables("HTTP_REFERER") <> "" then
PageInErrorHTTP = LCase(Mid(Request.ServerVariables("HTTP_REFERER"),1))
PageInErrorHTTP = LCase(Mid(Request.ServerVariables("QUERY_STRING"),5))
end if
T = Instr (PageInErrorHTTP,ServerName) + Len(ServerName)
PageInErrorRel = Mid(PageInErrorHTTP,T)
PageInErrorRel = Replace(PageInErrorRel,"%5f","_",1,-1,1)
PageInErrorResolved = Server.Mappath(PageInErrorRel)

UrlInErrorHTTP = LCase(Mid(Request.ServerVariables("QUERY_STRING"),5))
T = Instr (UrlInErrorHTTP,ServerName) + Len(ServerName)
UrlInErrorRel = Mid(UrlInErrorHTTP,T)
UrlInErrorResolved = Server.Mappath(UrlInErrorRel)
UrlInErrorRel = Replace(UrlInErrorRel,"%5f","_",1,-1,1)

if Instr(UrlInErrorHTTP,"favicon.ico") > 1 then ' When a user of IE adds a Favorite we get this 404
' which we don't need a message about
InServer = 1
end if

if Request.ServerVariables("REMOTE_ADDR") = Request.ServerVariables("LOCAL_ADDR") then
' When Site Server checks for the document title
InServer = 1 ' We also want to skip sending messages
end if

08-12-2004, 10:55 AM
that's great stuff,...

thanks helped me a lot,...