#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    8
    Rep Power
    0

    VBscipt / ASP question...


    I am creating a script that does the following:

    -User types URL: whatever.com/directory
    -User is redirected to 404.asp error page
    -404.asp page checks to see if whatever/directory is setup to forward to a specified URL, if it is, it redirects them to the URL. If not they stay on the 404.asp page.

    I've got this aspect working...Now, what I don't know how to do is strip out the URL so if a user types in whatever.com/directory -- (Html, asp, htm etc.. etc..) they will still be directed to the proper place.

    In other words, I only need it to read what comes after the /whatever in the URL line. That way if people type /directory.html /directory.asp etc... It will ignore the .asp .html or even .serjkwerjkwe for that matter. I just need it to ignore anything typed after that point and send them to the proper URL.

    I want to eliminate all user error but I don't want to have to enter each specic incorrect URL tag that they could type. I just want it to strip out the /directory and that's it.

    This is the code I have so far:


    <%
    'Get the user-requested URL
    requestedURL = Replace(Replace(Replace(Replace(Replace(Request.ServerVariables("QUERY_STRING"),"404;http://www.visionforum.com",""), "/", ""), ".asp", ""), ".htm", ""), ".html", "")

    If requestedURL = "doll" Then
    Response.Redirect("/beautifulgirlhood/productinfo.asp?number=72564")
    Else%>


    Any ideas how to best do this?
  2. #2
  3. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    PHP Code:
    Dim sURL
    Dim iPos

    sURL 
    Request.ServerVariables("QUERY_STRING")
    iPos Instr(8,Request.ServerVariables("QUERY_STRING"),"/")
    sURL Left(sURL,Len(sURL)-iPos
    I think that will do it for you. I don't have a server to test it right now or VB on this system.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    8
    Rep Power
    0
    Thanks.

    I can't seem to get that to work for some reason. I'll tweak with it a bit but I'm not exactly sure what the deal is. (Plus I don't really know what I am doing

IMN logo majestic logo threadwatch logo seochat tools logo