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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PURL

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,963
US
I have read that IIS7 and IIS8 servers allow you to implement web.config rewrites.

I would assume that this would be the best way to do a PURL (personlized URL).

Ex. - test.com/joesmith

Basically, using Classic ASP I would want to take the joesmith part of the URL and do a database lookup and display information on the page about Joe Smith, variable graphics, etc...

What is the best way to do this? Everything I see online is query string to pretty url or other examples.

Thanks.

Swi
 
Actually, parsing the query string after a "Not Found" response (404 status code) IS the best way I found for "classic" ASP scripts. I never could get ISAPIRewrite to work 'as expected' on IIS6 and IIS7, so I wrote a entire CMS for my own use based on that method.

This is the code that does the 'decoding' of the query string into the original requested URI
Code:
<%
dim TargURI

if instr(request.servervariables("QUERY_STRING"),"http") > 0 then
TargURI = request.servervariables("QUERY_STRING")
dim URIReq : URIReq = replace(TargURI,"404;[URL unfurl="true"]http://","")[/URL]
URIReq = replace(URIReq,request.servervariables("HTTP_HOST"),"")
URIReq = replace(URIReq,":80","")
end if

%>

URIReq is the original requested URI, after that it's just 'string slicing', database lookup and redirecting.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks. I will give it a shot and let you know how it goes.

Swi
 
Ok, tried it however it seems like you are looking for a query string.

I actually want to pass the URL like so:

test.com/swi
test.com/chris
etc....

Maybe I misunderstand but the code above looks to be searching for a query string.

Swi
 
The code I posted is meant to be in the .asp document that is served when a 404 response is given to a user agent, it then returns the requested URI minus the HTTP_HOST name.

So; for example, if a request is made for that is not found on the server, URIReq will contain a string of "/somefolder/" what happens after that is up to you, my code simply provides the original requested URI for you to do something with.



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Ok, so I created the ASP file and named it default.asp

When I browse to the URL Ex.- swiler.com/swiler I get the following error:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Should I name the ASP file something else or did I miss a step along the way?

Swi
 
default.asp is NOT a document that will run when a 404 'error' occurs, it is a document that WILL be served on a request for the folder it is located in.

Call the document anything you want, just as long as it is NOT default.asp or index.asp, then go into the IIS settings and configure the document name to be used for a 404 (Not Found) response, put the path and name of that .asp file with that code in it.

As a test, set it to print the value of URIReq directly to the browser, then request a URL that does not exist on the site, and if you has set it up correctly it will print the relative URI you rquested.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Ok, thanks. The server I am testing on is shared hosting with GoDaddy so I'll have to see what they allow. Thanks.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top