Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Location
    Spokane, WA
    Posts
    148
    Thanks
    4
    Thanked 4 Times in 4 Posts

    What site is the user trying to access

    I am devloping a page which will have several domains parked on it so the user can access the page from one of several domains. My issue is I want to find out with PHP what url they entered to get to my script, I assume just getting the referer won't work so is their a way to get the url they typed in? Because the page is going to vary slightly depending on the domain so i need to get the domain they entered to pull the correct info from my db.

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    take a look at the contents of the $_SERVER superglobal, I think (though I get the names confused sometimes) that $_SERVER['HTTP_HOST'] will contain what you're after

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Location
    Spokane, WA
    Posts
    148
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by GJay View Post
    take a look at the contents of the $_SERVER superglobal, I think (though I get the names confused sometimes) that $_SERVER['HTTP_HOST'] will contain what you're after
    from http://us3.php.net/reserved.variables
    'HTTP_HOST'
    Contents of the Host: header from the current request, if there is one.
    its kinda vauge but dosen't sound like it gives me what I want,

    from the same site
    'QUERY_STRING'
    The query string, if any, via which the page was accessed.
    this sounds like what I would use but I am not sure, I have to way to qucikly test this as of now, so if you can verify this i'd appriciate it.

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    PHP Code:
    print_r($_SERVER);
    echo 
    $_SERVER['HTTP_HOST']; 
    will tell you...


  •  

    Posting Permissions

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