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 was wondering if anyone could help me with parsing a URL so I can perform a database lookup in or to create a custom landing page.

PURL (personlized URL) - Ex. - test.com/JohnSample

I would like to parse the JohnSample bit off of the URL and perform a DB query on my ASP page to return information about the user before the page is rendered so it is specific to that person.

Any help would be greatly appreciated.

Thanks.

Swi

RE: PURL

Split Request.ServerVariables("PATH_INFO") on the '/' then read off the last array element.


Here's a function I use

CODE --> vbscript

public function GetPath()
   dim ThisPage
   ThisPage = Split(Request.ServerVariables("PATH_INFO"), "/")
   if FldrCount > ubound(ThisPage) then
   else
      GetPath = ThisPage(ubound(ThisPage))
   end if
end function 

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

And

GetPath = ThisPage(ubound(ThisPage))

Should be

GetPath = ThisPage(ubound(ThisPage)-1)

If you need to remove the document name (default.asp) from the URI.

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)
Thank you very much. I will give it a shot.

Swi

RE: PURL

(OP)
Would this be reliable with all browsers? Thanks.

Swi

RE: PURL

Browsers have nothing to do with server side code.

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)
Agreed. Thank you for the response. Just had a colleague metion something to me.

Swi

RE: PURL

(OP)
This works well however how do I rewrite the URL and display the default.asp file and do a database lookup to display the variable content on the page.

Any help is greatly appreciated.

Thanks.

Swi

RE: PURL

Not sure all that you are asking, so sorry if i'm being too simplistic or general...

how do I rewrite the URL and display the default.asp file
do a response.redirect?

do a database lookup to display the variable content on the page
create connection string, do a database lookup, response.write what you want?

RE: PURL

(OP)
Basically there are two ways you can do this from what I understand.

1. Use a query string: website.com?name=Swiler
2. Use an custom 404 error page in IIS to rewrite the URL and pass a session variable to do the DB lookup

Not really sure which way I want to go. I guess it depends on what the client wants.

Pretty URL = website.com/Swiler
Query String (embedded in maybe a QR code) = website.com?name=Swiler

If anyone has any alternatives let me know.

Thanks.

Swi

RE: PURL

Yes, that is my understanding as well. I don't know of another alternative besides those two.

The custom error page makes the URL look nicer and easier to type, remember etc., but requires a change to IIS to implement (albeit a minor one). The query string is faster to implelent, but the URL will not be as clean.

RE: PURL

(OP)
Yep. Thank for the confirmation and feedback.

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