...

View Full Version : ASP directory resolving!



GzArIa
08-08-2004, 01: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,

www.mydomain.com/membername

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,...

cheers
GzArIa

Roy Sinclair
08-09-2004, 04: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.

GzArIa
08-11-2004, 09: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.
GzArIa

Roy Sinclair
08-11-2004, 10: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))
else
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

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

thanks helped me a lot,...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum