Strip Query String from url

S

Scott

Below is a script I use to strip everything from a url except the actual
page. So for example, "http://www.cnn.com/mypage.asp?article=5&id=20"
becomes "mypage.asp".

I'm looking for a script that will strip any querystring from a url if it
exists, so my result would be "http://www.cnn.com/mypage.asp".

Can someone help me modify my script below to achieve this result? I'm
horrible with string functions.


CODE to Get URL **************

Right(Request.ServerVariables("SCRIPT_NAME"),Len(Request.ServerVariables("SCRIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))
 
E

Evertjan.

M

McKirahan

Scott said:
Below is a script I use to strip everything from a url except the actual
page. So for example, "http://www.cnn.com/mypage.asp?article=5&id=20"
becomes "mypage.asp".

I'm looking for a script that will strip any querystring from a url if it
exists, so my result would be "http://www.cnn.com/mypage.asp".

Can someone help me modify my script below to achieve this result? I'm
horrible with string functions.


CODE to Get URL **************
Right(Request.ServerVariables("SCRIPT_NAME"),Len(Request.ServerVariables("SC
RIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))


Dim strRSV
strRSV = Request.ServerVariables("SCRIPT_NAME")
Dim strURL
strURL = Left(strRSV,InStr(strRSV,"?") -1)
 
S

Scott

Thank you.

McKirahan said:
Right(Request.ServerVariables("SCRIPT_NAME"),Len(Request.ServerVariables("SC
RIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))


Dim strRSV
strRSV = Request.ServerVariables("SCRIPT_NAME")
Dim strURL
strURL = Left(strRSV,InStr(strRSV,"?") -1)
 
A

Anthony Jones

Scott said:
Below is a script I use to strip everything from a url except the actual
page. So for example, "http://www.cnn.com/mypage.asp?article=5&id=20"
becomes "mypage.asp".

I'm looking for a script that will strip any querystring from a url if it
exists, so my result would be "http://www.cnn.com/mypage.asp".

Can someone help me modify my script below to achieve this result? I'm
horrible with string functions.


CODE to Get URL **************

Right(Request.ServerVariables("SCRIPT_NAME"),Len(Request.ServerVariables("SC
RIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))

The SCRIPT_NAME server variable does not contain query string. Nor does it
contain protocol or host name it only contains the absolute virtual path to
the script.
 
E

Evertjan.

Dave Anderson wrote on 04 sep 2006 in
microsoft.public.inetserver.asp.general:
If you intend this for a link, simply use this:

<a href="<%=Request.ServerVariables("URL")%>"> ... </a>

No need to parse anything.

Certainly, but is it useful to link tot the page itself?
 
D

Dave Anderson

Evertjan. said:
Certainly, but is it useful to link tot the page itself?

Yes, especially when the querystring has session-related nonsense in it,
such as the way youtube embeds the search query in subsequent links. Perhaps
I should have written it this way:

<a href="<%=Request.ServerVariables("URL")%>">Permalink</a>
 
E

Evertjan.

Dave Anderson wrote on 04 sep 2006 in
microsoft.public.inetserver.asp.general:
Yes, especially when the querystring has session-related nonsense in
it, such as the way youtube embeds the search query in subsequent
links. Perhaps I should have written it this way:

<a href="<%=Request.ServerVariables("URL")%>">Permalink</a>

Yes. I see some sense in an inc file with:

<form
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top