How can you get only the part of the URL after the domain using php

Discussion in 'PHP' started by Webed4it, Nov 1, 2010.

  1. #1
    Hi

    I am working on a Joomla site with SEF switched on.

    I want to have a different background on each page and I plan to do this by setting the main container div class to the name of the page and then setting the background image in the css file. If the URL is domain.com/mypage How would I get only the mypage part of the URL?

    If this is not a good way of setting a different background on each page please tell me a better way.

    Thanks
     
    Webed4it, Nov 1, 2010 IP
  2. leh

    leh Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    echo $_SERVER['REQUEST_URI']; will output: '/mypage' using your example url.
     
    leh, Nov 1, 2010 IP