INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

PURL

PURL

(OP)
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

RE: PURL

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 --> vbScript

<%
dim TargURI

if instr(request.servervariables("QUERY_STRING"),"http") > 0 then
TargURI = request.servervariables("QUERY_STRING")
dim URIReq : URIReq = replace(TargURI,"404;http://","")
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

RE: PURL

(OP)
Thanks. I will give it a shot and let you know how it goes.

Swi

RE: PURL

(OP)
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

RE: PURL

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 http://domain.tld/somefolder/ 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

RE: PURL

(OP)
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

RE: PURL

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

RE: PURL

(OP)
Ok, thanks. The server I am testing on is shared hosting with GoDaddy so I'll have to see what they allow. Thanks.

Swi

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close