SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple question about request_uri

    I know this is a pretty simple question, but I cannot figure it out. What would I need to do if I wanted to show something if any page on a site was being called except for the main page at www.domain.com? I've tried the following which I think should work but it doesn't:

    PHP Code:
    if(!isset($_SERVER['REQUEST_URI']))
        echo 
    'show me'
    also tried

    PHP Code:
    if($_SERVER['REQUEST_URI'] == '')
        echo 
    'show me'
    John Saunders

  2. #2
    SitePoint Guru gavwvin's Avatar
    Join Date
    Nov 2004
    Location
    Cornwall, UK
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if($_SERVER['PHP_SELF']=="/index.php") {
      echo 
    "show me";

    (where index.php is actually the name of the script... REQUEST_URI is the file requested, PHP_SELF is the file served- so by using PHP_SELF it doesn't matter what the url is. If you use it in a file that is included it still returns the filename of the main script so the above should still work.

  3. #3
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! I guess I just stupidly assumed since nothing is showing up in the address bar after the .com that request_uri would have been empty.
    John Saunders


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
  •