PHP header redirect not working

前端 未结 13 2084
小蘑菇
小蘑菇 2020-12-05 12:00

I know this has been covered before but I cannot find an answer to this,

I have always used this;

header(\"Location: http://www.website.com/\");
exit         


        
13条回答
  •  独厮守ぢ
    2020-12-05 12:30

    Try:

    error_reporting(E_ALL | E_WARNING | E_NOTICE);
    ini_set('display_errors', TRUE);
    
    
    flush();
    header("Location: http://www.website.com/");
    die('should have redirected by now');
    

    See what you get. You shouldn't use ^ (xor) in your error_reporting() call because you're unintentionally asking for all errors EXCEPT notices and warnings.. which is what a 'headers already sent' error is.

    Edit:

    Also try putting flush() right above your header() call.

提交回复
热议问题