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!

Create URL that does not map directly to file or folder

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
I'd like to publish URLs of the form


etc but without physically setting up individual folders on the web site to correspond to each of the cities. I'd want to direct visitors to an ASP page that would parse the URL to extract the city and trigger logic accordingly. Can this be done - perhaps by directing 404 page not found errors to the ASP page I have in mind?

Thanks in advance.
 
Thanks for the suggestion. To be brutally honest I'd prefer to lose the questionmark. I'd rejected my "intuitive" approach that would have used something along similar lines (e.g. ?city=liverpool) for the same reason. Your suggestion is a step better though!

I'm tempted to trap 404 errors but I'm having problems when I direct to a .asp file rather than .html.
 
Create a 404.asp error handling page.

For IIS: look under "Custom Errors" for the 404 error. Default it will redirect to an .HTML page. Point it to your 404.asp page.

In 404.asp check for city name. If not found, then it is really a "file not found" error!

 
Thanks foxbox. I've been giving that approach a try but I'm not sure how I retrieve the full text (or just the trailing city text) after the custom error page has been called. I can't see anything in the Request.ServerVariables collection.

Any ideas?
 
The QUERY_STRING does return the info I need. I'm not sure how I missed this. I've been testing on both local and remote machines with different results and problems. I've also occasionally been calling the error trap page explicitly (so QUERY_STRING is blank as there is no question mark and the error page itself exists). I must have got confused - duh.


aha, so my suggestion is working....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top