ririe44 Posted August 8, 2009 Share Posted August 8, 2009 So I'm playing with plaincart... and I'm having a problem with the file path retrieval. Here's the code that is setting the path.... // setting up the web root and server root for // this shopping cart application $thisFile = str_replace('\\', '/', __FILE__); $docRoot = $_SERVER['DOCUMENT_ROOT']; $webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile); $srvRoot = str_replace('library/config.php', '', $thisFile); define('WEB_ROOT', $webRoot); define('SRV_ROOT', $srvRoot); Then, for example, I have this function to check a user: function checkUser() { // if the session id is not set, redirect to login page if (!isset($_SESSION['plaincart_user_id'])) { header('Location: ' . WEB_ROOT . 'admin/login.php'); exit; } So... when testing this, I goto my url: http://www.michaelririe.com/mrstore/admin. This should direct me to the login.php file, but instead it takes me too http://www.michaelririe.com/mrstore/admin/mrstore/admin/login.php. This is happening all through the program with image paths, links, etc. I'm not sure how to fix the Web Root portion so that it all comes up right... any ideas? Link to comment https://forums.phpfreaks.com/topic/169319-web-root-problem/ Share on other sites More sharing options...
ririe44 Posted August 8, 2009 Author Share Posted August 8, 2009 So, when I echo $webRoot, I get "mrstore/"... which makes sense why everything is so off... I'm guessing it should read the full url for it to work right, right? So, I need $webRoot to equal "http://www.michaelririe.com/mrstore/" Then, in the even of the code above, it would have returned correctly to the login.php file... So, how do I get $webRoot to come through right? Link to comment https://forums.phpfreaks.com/topic/169319-web-root-problem/#findComment-893464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.