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!

looking for "//" inside url request

Status
Not open for further replies.

ralph4208w

Programmer
Aug 29, 2006
13
US
Hi,

I'm trying to use vbscript within an ASP page (asp 3.0) to determine whether the person visits my site with or without an extra "/"....

or
<-- notice the "//"

Any ideas on how to record this info? I've looked at ServerVariables, but have not yet found anything that works.

Thanks in advance.
 
The InStr function would be my suggestion. There is probably a more effiecient way to do this but this would work:
Code:
Dim strUrl
strUrl = [URL unfurl="true"]http://www.mysite.com/hello.html[/URL]
'strip out http://
strUrl = Replace(strUrl, "[URL unfurl="true"]http://",[/URL] "")
'Check remaining url string for //
If InStr(strUrl, "//") = 0 Then
  'Most Likely They Won't Add // So Check For That First
  Response.Write "No Error"
Else
  Response.Write "Error - // Found"
End If
Hope that helps.
 
Technicality but:
Code:
strUrl = [URL unfurl="true"]http://www.mysite.com/hello.html[/URL]
should read:
Code:
strUrl = "[URL unfurl="true"]http://www.mysite.com/hello.html"[/URL]
If you're requesting from a form then:
Code:
strUrl = Request.Form("url")
 
Thanks for the suggestions. Maybe I should rephrase the question: How do I obtain the full URL address that a person has typed? So, I'd like to know if a person typed the correct address or if they entered "//" when it wasn't needed.

You may be wondering why I ask this question. The site is working fine, but the extra "//" is confusing one of my cookies. Before processing the page's logic I'd like to remove the extra slash and then have the cookie processing occur.

Thanks in advance.
 

This is what I've used:
Code:
Request.ServerVariables("URL")
I think this returns the virtual path when their last navigation was also in your site. I'm not sure what happens when the hit your page from outside.

Then you could check for "//" using the methods posted above.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top