1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do i get domain from url ?

Discussion in 'PHP' started by DarkMatrix, May 6, 2015.

  1. #1
    Hello

    I have many Domains and i want to add parking page for all domains for example
    " XYZABC,com is under construction"

    so how to grab domain from browser addressbar and show it on parking page

    Help Appreciate
    Thanks
     
    Solved! View solution.
    DarkMatrix, May 6, 2015 IP
  2. #2
    You wouldn't be grabbing it "from the address bar" -- that's client side, you have ZERO access to that. What you would want to parse is the $_SERVER['REQUEST_URI'] (that's an I not an L)

    Run that through:

    http://php.net/manual/en/function.parse-url.php

    echo parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST);
    Code (markup):
     
    deathshadow, May 6, 2015 IP
    DarkMatrix likes this.
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #3
    Oh, and pay a good deal of attention to $_SERVER, there's a LOT of useful information you can do stuff with in there.

    http://php.net/manual/en/reserved.variables.server.php

    I parse REQUEST_URI a lot in my own code -- ever see people use .htaccess redirects to try and turn the URI into $_GET? Waste of time and needlessly complicated, and very fragile. Instead I use a whitelist of files to serve, redirecting all other files to my index.php to then parse out the path of REQUEST_URI, exploding it by slashes to use it that way. Has the nice side effect that you can mix getdata with the redirect, something the other approach cannot do.
     
    deathshadow, May 6, 2015 IP
  4. DarkMatrix

    DarkMatrix Active Member

    Messages:
    310
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    55
    #4
    I will pay good attention

    Thanks
     
    DarkMatrix, May 6, 2015 IP