HTAccess and PHP URL's

Discussion in 'PHP' started by JosS, Jan 15, 2007.

  1. #1
    I have a slight problem, and after some reading on PHP.net I'm still unable to find out how to get past it.

    If I have a script that runs like this,

    www.mysite.com/product.php?id=games

    but I've mod_rewrite'ed the URL's so they turn out like www.mysite.com/products/games

    If I was to echo the current page in the footer like so:

    <?php echo $_SERVER['PHP_SELF'] ?>

    It echos product.php.

    Is there any way I can get it to echo www.mysite.com/products/games?

    Any help much appreciated.

    Thanks!
     
    JosS, Jan 15, 2007 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php echo $_SERVER['PHP_SELF'] . "?"; ?> will show what you want. But, this is a display only feature for the visitor.

    But, why the question mark?
     
    clancey, Jan 15, 2007 IP
  3. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #3
    PHP_SELF will show the name of the php script. REQUEST_URI will show the requested URI.

    <?php echo $_SERVER['REQUEST_URI']; ?>
    PHP:
     
    rodney88, Jan 15, 2007 IP
  4. JosS

    JosS Guest

    Messages:
    369
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hmm, that doesn't do it quite right.

    Is there any way to echo the current page in how it reads in the actual address bar?
     
    JosS, Jan 15, 2007 IP
  5. JosS

    JosS Guest

    Messages:
    369
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I'll try Rodney's solution out!

    Edit: Perfect mate, much appreciated!
     
    JosS, Jan 15, 2007 IP