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; Link to comment https://forums.phpfreaks.com/topic/167813-solved-create-a-page-location-using-_serverrequest_uri/ 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']; Link to comment https://forums.phpfreaks.com/topic/167813-solved-create-a-page-location-using-_serverrequest_uri/#findComment-885045 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... Link to comment https://forums.phpfreaks.com/topic/167813-solved-create-a-page-location-using-_serverrequest_uri/#findComment-885051 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... Link to comment https://forums.phpfreaks.com/topic/167813-solved-create-a-page-location-using-_serverrequest_uri/#findComment-885061 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... Link to comment https://forums.phpfreaks.com/topic/167813-solved-create-a-page-location-using-_serverrequest_uri/#findComment-885194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.