Shaun Posted May 8, 2008 Share Posted May 8, 2008 Ok, so I want to do something like this <? header(”Status: 404 Not Found”); header("location: http://addresshere.com"); ?> obviously this is going to cause problems with headers already being sent.. so how would I do something like this without having to rely on meta tags to redirect? thanks, Shaun Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/ Share on other sites More sharing options...
dingus Posted May 8, 2008 Share Posted May 8, 2008 try adding this on the first line ob_start(); Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-535851 Share on other sites More sharing options...
Shaun Posted May 8, 2008 Author Share Posted May 8, 2008 thanks dingus, but it still returns header errors. Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-536011 Share on other sites More sharing options...
BlueSkyIS Posted May 8, 2008 Share Posted May 8, 2008 your code should work. are you sending anything to the browser before the header() calls? is there ANYTHING before the code you posted? if there is nothing before this, it maybe the problem is the back-double-quotes in the first header(). try changing it to this with regular double-quotes. header("Status: 404 Not Found"); Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-536020 Share on other sites More sharing options...
discomatt Posted May 8, 2008 Share Posted May 8, 2008 Why not just use Status 404 and then have an htaccess file pointing to http://addresshere.com on 404 errors. Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-536021 Share on other sites More sharing options...
BlueSkyIS Posted May 8, 2008 Share Posted May 8, 2008 browser may not automatically go to apache error page after sending a 404. or you may want a different 404 page for the redirect. i use this code for both: header("Status: 404 Not Found"); header("location: /404.php"); exit; Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-536023 Share on other sites More sharing options...
discomatt Posted May 8, 2008 Share Posted May 8, 2008 I don't understand the purpose of header("Status: 404 Not Found"); then. Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-536027 Share on other sites More sharing options...
BlueSkyIS Posted May 8, 2008 Share Posted May 8, 2008 you're telling the browser "Page Not Found" with 404. then you tell the browser where to go with Location. By the time you get to PHP, Apache has already done it's work. Apache won't tell the browser where to go on a 404, so PHP has to do it. Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-536050 Share on other sites More sharing options...
Shaun Posted May 9, 2008 Author Share Posted May 9, 2008 Thank you bluesky, adding the exit; to the end got it working perfectly Link to comment https://forums.phpfreaks.com/topic/104703-solved-multiple-header-information-in-one-script/#findComment-537179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.