Re: Problem with header redirection
| From: | Marek Kilimajer | Date: | Mon, 21 Apr 2003 16:49:14 +0000 |
| Subject: | Re: Problem with header redirection | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144667@lists.php.net to get a copy of this message | ||
http specs require full URI to be used in Location header, try using it.
Steve M wrote:
I'm having some weird problems redirecting with 'header', which may be to do with the path I'm feeding it. Here's the set-up: there's a folder in my root directory called 'market' and a file in there called 'mktad.php'. In that file, I look at a session var to see if the user is logged-in and, if not, bounce them to a log-in page with: $_SESSION['ref_page'] = $_SERVER['PHP_SELF'] ; header("Location: ../signin.php") ; This works fine and we arrive at signin.php (which is in the root directory) where (for the time being, during development) I echo the session var above and it displays as: /market/mktad.php (on my local system) /test/market/mktad.php (on the shared server - this site is in the temporary sub-folder 'test' during development) I then go through the various login routines and, when everything is tickety-boo, I set various sessions vars and use: header("Location: ".$_SESSION['ref_page']); Here's where the problem comes. On my WinXP local system, all works fine and we arrive back at the original page with the user logged-in. On the shared-server hosting system, however, it seems to make an attempt to load the required page, but it all screws up with pictures not being found. In the browser's (IE6) filepath window, it still shows the signin.php path and filename, not the target one. I thought about stripping the leading '/' from the path, so that it becomes relative to signin.php, which still works fine on my local system, but I can't yet test it on the shared server because the test site is in a subdirectory that screws up all the path info. Any thoughts would be appreciated. Is there a smarter way of defining the path rather than PHP_SELF? I've tried using other things like __FILE__ etc, but have encountered problems with everything else I've tried.