SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Http-referer

  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Http-referer

    I have a web page on which I would like to show the referring domain. I recently learned that HTTP_REFERER can be used to show the complete url by using:

    strURL = Request.ServerVariables("HTTP_REFERER")

    However, I was wondering if it's possible to somehow strip out all parts of the URL other than the domain itself. In other words - if someone is referred to my web page from e.g.

    http://www.sitepoint.com/forums/newthread.php?do=postthread&f=148
    or:
    http://www.sitepoint.com/?epl=387687fswoodwi

    .. then I would like to only show www.sitepoint.com on my web page.

    Anyone know how to go about this? Any help will be greatly appreciated!
    Last edited by Netherland; Dec 17, 2006 at 20:03.

  2. #2
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here's a list of all the server variables: http://www.w3schools.com/asp/coll_se...riables.asp#sv

    i think you might have to trim everything right of the last "/". if you use a combination of the mid() function and instr(), you can work out where the last slash is...

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for your suggestion, Bill!

    To be honest - I'm a total nitwit when it comes to programming/scripting, but I will see if I can somehow get it working with the functions you mentioned.

    Meanwhile, if any of you know the code to accomplish this, that would be even better, of course

    Alex

  4. #4
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's very simple:

    tmparray = split(strURL,"/")
    domain = tmparray(2)

  5. #5
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ark2 View Post
    it's very simple:

    tmparray = split(strURL,"/")
    domain = tmparray(2)
    Wow, many thanks!

    I tried the following script code based on your suggestion and it seems to work perfectly:

    <&#37;
    Dim strURL, tmparray, domain
    strURL = Request.ServerVariables("HTTP_REFERER")
    tmparray = Split(strURL, "/")
    domain = tmparray(2)
    Response.Write domain
    %>

    As I said - I'm a scripting nitwit, so if you see anything that's not logical, please let me know


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •