SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot CDitty's Avatar
    Join Date
    Feb 2000
    Location
    Memphis Tn
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Finding a site's url prefix & suffix

    I am trying to find the prefix & suffix of a url of a site via php. I have been pretty successful so far, but I have run into a small roadblock. I can find these easily enough for urls like http://www.redhotsweeps.com & http://redhotsweeps.com. But I can't seem to get it when the url is like http://games.redhotsweeps.com.

    Any ideas?

    PHP Code:
    $r_url explode("."strtolower($HTTP_REFERER)); // Breaks the referering url up at the . points to give the site name
    if($r_url[0] != "http://www"){
        
    $r_url[2] = $r_url[1];
        
    $r_url[1] = substr($r_url[0], 7);
    }
    $suffix_url explode("/"$r_url[2]); // Break the $r_url[2} variable up at the / to give the site suffix. (.com, .net, etc)
    $site_url strtolower("$r_url[1].$suffix_url[0]"); // combines the whole thing into 1 string for comparison and lowercases it. 

  2. #2
    SitePoint Addict
    Join Date
    Nov 2000
    Location
    London, UK
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if this'll work, but try using $SERVER_NAME instead of $HTTP_REFERER it might work better....

    ... what's the world coming to?

  3. #3
    SitePoint Zealot CDitty's Avatar
    Join Date
    Feb 2000
    Location
    Memphis Tn
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found it. Unfortunately, it won't work. I am calling this script from another server. Need the domain for the calling server.

    ie....http://games.redhotsweeps.com calls a script on http://www.mysite.com. Need to see who called it specifically.

    Sorry I didn't specify that earlier.

  4. #4
    SitePoint Addict
    Join Date
    Nov 2000
    Location
    London, UK
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well then, I have no idea

    ... what's the world coming to?


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
  •