PHP URI

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor

    #1

    PHP URI

    How can I get the URI for a page? For example, I want $domain =
    "http://www.domain.com" in the page http://www.domain.com/page.php.

    Thanks,
    Trevor

  • Justin Koivisto

    #2
    Re: PHP URI

    Trevor wrote:[color=blue]
    > How can I get the URI for a page? For example, I want $domain =
    > "http://www.domain.com" in the page http://www.domain.com/page.php.[/color]

    That will depend on a bunch of different things, mostly to do with your
    server setup...

    Here's something to get you started (in apache):
    $urI = $_SERVER['REQUEST_URI']; // includes query string...
    $proto=substr($ _SERVER['SERVER_PROTOCO L'],0,strpos('/',$_SERVER['SERVER_PROTOCO L']));
    $port=$_SERVER['SERVER_PORT'];
    $host=$_SERVER['HTTP_HOST'];
    $urL = strtolower($pro to).'://'.$host.':'.$po rt.$urI;

    When in doubt, check the output of phpinfo()

    --
    Justin Koivisto, ZCE - justin@koivi.co m

    Comment

    • Trevor

      #3
      Re: PHP URI

      Excuse me, I ment URL, not URI. I just want the domain name.

      Comment

      • Justin Koivisto

        #4
        Re: PHP URI

        Trevor wrote:[color=blue]
        > Excuse me, I ment URL, not URI. I just want the domain name.
        >[/color]

        $_SERVER['HTTP_HOST']

        --
        Justin Koivisto, ZCE - justin@koivi.co m

        Comment

        • Trevor

          #5
          Re: PHP URI

          Thanks, that's what I needed.

          Comment

          • Trevor

            #6
            Re: PHP URI

            Thanks, that's what I needed.

            Comment

            Working...