PHP: header ("Location ... suddenly stopped working
<?php <-- check for whitespace before this (by popular demand)
error_reporting(E_ALL); // report all error messages
header("Location: http://www.google.com"); // leave a space between name and value
?> <-- remove this, or check for whitespace after it
My thinking is that after your final closing tag, or before opening it, the backslider character appears.
a source to share
I had the same issue where redirects seemed to suddenly stop working.
It ended up on a new line before a tag <?php
that I accidentally added in some obscure include file I was using.
One of the methods I have used to troubleshoot is the Networking tab in the Google Chrome developer console . I saw a new line before 200 OK
that was telling me there was something wrong with one of my files.
a source to share
I had a problem like this. I used my own PHP MVC pattern. There was actually no error, all of a sudden my redirects stopped working. I have read tons of document. But finally added ob_start();
to the index page. And it worked.
Note: Before redirecting, you must flush the buffer. Otherwise, it cannot be redirected.
a source to share