chennaibala Posted December 22, 2009 Share Posted December 22, 2009 hi frds, i want to redirect from one page to other directory php page.it poosible? assume rite now we are in login page.after submit i should redirect my page called gift.php which in other sub directory(newyear) from /login.php to /newyear/gift.php. header('Location: /newyear/gift.php); it not works..any other way? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/ Share on other sites More sharing options...
Deoctor Posted December 22, 2009 Share Posted December 22, 2009 try like this echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=/newyear/all.html\">"; Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/#findComment-982148 Share on other sites More sharing options...
jacko310592 Posted December 22, 2009 Share Posted December 22, 2009 if you wrote the code as you did in your post, then your missing the second apostrophe: header('Location: ./newyear/gift.php'); if you did type it correctly within your code, then what errors do you recieve (if any) and what is your entire code for the login submit page? Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/#findComment-982153 Share on other sites More sharing options...
chennaibala Posted December 22, 2009 Author Share Posted December 22, 2009 it not redirecting.it saying The page cannot be found..http 404 error.actually gift.php is present in newyear folder. Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/#findComment-982165 Share on other sites More sharing options...
jacko310592 Posted December 22, 2009 Share Posted December 22, 2009 how are your directory paths structured?, am i correct in thinking the two file paths go as follows... RootDir/login.php RootDir/newyear/gift.php if they do go like this then i am not sure why your recieving a 404 error BUT, if your directories go somthing like this... RootDir/someDir/login.php RootDir/someDir/newyear/gift.php then you need to remember to add a dot before the forward slash within the header code to make sure its looking for the redirect page from the current directory and not the root directory: header('Location: ./newyear/gift.php'); Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/#findComment-982629 Share on other sites More sharing options...
chennaibala Posted December 23, 2009 Author Share Posted December 23, 2009 yes..i did..still not redirecting.. Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/#findComment-982901 Share on other sites More sharing options...
Deoctor Posted December 23, 2009 Share Posted December 23, 2009 yes..i did..still not redirecting.. use ur redirection like this echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=./newyear/gift.php\">"; it should work if the gift.php is there in that folder. Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/#findComment-982907 Share on other sites More sharing options...
Lamez Posted December 23, 2009 Share Posted December 23, 2009 <?php $file = 'newyear/gift.php'; $count = 0; while(!file_exists($file) && $count <= 100){ $crumbs = '../'; $file = $crumbs.$file; $count++; } header('Location: '.$file); ?> That should do it Quote Link to comment https://forums.phpfreaks.com/topic/185992-redirect-from-one-page-to-other-directory-php-page/#findComment-982914 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.