Access path as querystring?

snooper

Perch
Hi all

is it possible in ASP to access a part of the URL as a querystring?

example: www.site.com/folder

can the index.asp in the root of this site show a page that is based on the "folder" parameter - instead of simply showing the index.asp file that sits inside of "folder"?

another example: goto www.whois.sc now goto www.whois.sc/cnn.com
obviously there isnt a folder for every single domain name within the whois.sc site. so how do they access the URL as a parameter?

another exmple (i'm on a roll, don't stop me): http://profiles.yahoo.com/harry


so all i (theoretically) have is one page in my site - call it www.site.com/default.asp but thru that one page i can access info about New York if i go to www.site.com/ny and LA if i go to www.site.com/la - all in that one default.asp page.
basically what i am trying to achieve is to build a friendly system for visitors to remember the URL (like www.site.com/ny), but also to allow the client (site owner) to open new locations as he needs, without me having to create a new folder and pages for him everytime.


can this sort of thing be done in ASP? and does JH support this kind of thing?

many thanks!
 
As far as I know that can only be done with ASP together with a custom ISAPI filter which you won't be able to install.

In ASP.net you can implement IHttpHandler instead of writing an ISAPI filter, but that still requires you to mess with the ASAPI settings under some circumstances. I'm not sure if yours would since you only use directories and not file extensions which don't normally go through ASP.net processing..

Another method in ASP.net I think you'd be able to use can be found here: http://www.codetoad.com/asp.net_ma_searchenginefriendly.asp
 
snooper said:
Hi all

is it possible in ASP to access a part of the URL as a querystring?

example: www.site.com/folder

can the index.asp in the root of this site show a page that is based on the "folder" parameter - instead of simply showing the index.asp file that sits inside of "folder"?
I do this now using request.servervariables("QUERY_STRING"), removing my domain name from the string, and then checking to see if the remaining text is a member name. The URL's are typically "http://mydomain.com/membername" in my case. Then I just redirect to a member.asp?id=xx page.
 
Logan said:
I do this now using request.servervariables("QUERY_STRING"), removing my domain name from the string, and then checking to see if the remaining text is a member name. The URL's are typically "http://mydomain.com/membername" in my case. Then I just redirect to a member.asp?id=xx page.

but what page do you do the request on?
 
snooper said:
but what page do you do the request on?
Oops, sorry, left that part out eh? I setup a 404.asp page and setup HSphere to use this page on 404 errors. Then the ASP code is in this page. I think IIS sends a querystring like "404;/page.asp" to the error page where /page.asp is the page that the user entered that doesn't exist.
 
Logan said:
Oops, sorry, left that part out eh? I setup a 404.asp page and setup HSphere to use this page on 404 errors. Then the ASP code is in this page. I think IIS sends a querystring like "404;/page.asp" to the error page where /page.asp is the page that the user entered that doesn't exist.

mmm... that actually quite clever!! ;)
hope you dont mind if i borrow that one - its amazingly simple! so all you basically need is a default, a 404 and a display page!
 
Can you stop it from returning a 404 result code though (I've never tried that)? Otherwise browsers with 'friendly error messages' might not display anything.
 
Logan said:
I do this now using request.servervariables("QUERY_STRING"), removing my domain name from the string, and then checking to see if the remaining text is a member name. The URL's are typically "http://mydomain.com/membername" in my case. Then I just redirect to a member.asp?id=xx page.

i just wanted to say it's a briliant idea! great job!
:))
 
Back
Top