SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to extract hostname from url.

    Hello, want to extract the domain from the referer url so it if is:

    http://www.domain.com/somepage.html

    I want to get just:

    domain.com


    I haven't a clue how to do it. Thanks.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    print $_SERVER['HTTP_HOST']; // www.domain.com 
    or

    http://www.php.net/manual/en/function.parse-url.php
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



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
  •