bugzy Posted August 17, 2012 Share Posted August 17, 2012 I have this problem on my path and I'm confused on what to use among relative, document or root relative path. I'm doing this on my local machine so absolute path is not in the option.. All my admin pages are on a folder named "ADMIN" I have this function for my session <?php session_start(); function logged_in() { return (isset($_SESSION['member_id']) || isset($_COOKIE['member_id'])); } function confirm_logged_in() { if(!logged_in()) { me_redirect_to('login.php'); } } ?> the problem here is on the line me_redirect_to('login.php'); Since my I'm calling the fucntion on all admin pages.. it will keep on saying that The requested URL /prac/admin/login.php was not found on this server. It's adding the folder on the url where the admin pages is located.. it's supposed to be only /prac/login.php Anyone? Quote Link to comment Share on other sites More sharing options...
xyph Posted August 17, 2012 Share Posted August 17, 2012 ../login.php ? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 17, 2012 Share Posted August 17, 2012 me_redirect_to('/prac/login.php'); What is the me_redirect_to code? Quote Link to comment Share on other sites More sharing options...
bugzy Posted August 17, 2012 Author Share Posted August 17, 2012 ../login.php ? xyph problem with that is, I'm going to also use that function on other files that are located on different root level including the files that are located on the root. So I'm looking for a solution that will cover all files regardless of where their locations are.. Quote Link to comment Share on other sites More sharing options...
bugzy Posted August 17, 2012 Author Share Posted August 17, 2012 me_redirect_to('/prac/login.php'); What is the me_redirect_to code? jesirose function me_redirect_to( $location = NULL ) { if ($location != NULL) { header("Location:{$location}"); exit; } } Quote Link to comment Share on other sites More sharing options...
xyph Posted August 17, 2012 Share Posted August 17, 2012 ../login.php ? xyph problem with that is, I'm going to also use that function on other files that are located on different root level including the files that are located on the root. So I'm looking for a solution that will cover all files regardless of where their locations are.. Well, you're either going to have to use absolute paths (you SHOULD be, the Location header spec requires an absolute URI), or your're going to have to calculate where your executing page is in relation to the root. http://php.net/manual/en/function.header.php#refsect1-function.header-notes HTTP/1.1 requires an absolute URI as argument to ? Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 17, 2012 Share Posted August 17, 2012 So...did you try what I said?? Quote Link to comment Share on other sites More sharing options...
bugzy Posted August 17, 2012 Author Share Posted August 17, 2012 So...did you try what I said?? It's working now... Though I might use absolute path instead to avoid more headaches in the future Thanks! 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.