matbourne Posted July 28, 2009 Share Posted July 28, 2009 I created a test page to try and create a page location depending on the current page using $_SERVER['REQUEST_URI']. This works on a seperate test page and the code below gives me the desired result. Desired result: ./path/foldername/currentpage.php However, when using the same code in my live website the result is as below: Undesired result: ./path/foldername/ Can anyone help me with this please as i am pulling out hair now! All help greatly appreciated Forgive the vagueness of the code, i don't want to give too much away... // Set $currentPage as current page $currentPage = $_SERVER['REQUEST_URI']; // Remove / from $currentPage $currentPage = $str_replace("/", "", $currentPage); $pageLocation = $path . "foldername" . $currentPage; Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 28, 2009 Share Posted July 28, 2009 Do you get what you expect when running the following on your live server? echo $_SERVER['REQUEST_URI']; Quote Link to comment Share on other sites More sharing options...
matbourne Posted July 28, 2009 Author Share Posted July 28, 2009 Thanks for the quick reply... I'm sure I already checked that, but just tried it again. It works on my included pages but not on my main index.php page that contains all the site structure and includes... Quote Link to comment Share on other sites More sharing options...
matbourne Posted July 28, 2009 Author Share Posted July 28, 2009 Thanks for the quick reply... I'm sure I already checked that, but just tried it again. It works on my included pages but not on my main index.php page that contains all the site structure and includes... I need this to work on my main index.php page and other main pages... Quote Link to comment Share on other sites More sharing options...
matbourne Posted July 28, 2009 Author Share Posted July 28, 2009 I solved this myself in the end. It wasnt working because my current location was http://www.sitename.co.uk/ When tested on a direct call to a page ie http://www.sitename.co.uk/index.php it worked flawlessly... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.