@header('Location: ' . $uri);
But it only seldom happens,what's the problem?
@header('Location: ' . $uri);
But it only seldom happens,what's the problem?
Perhaps your script is sending some output before it for some reason. Remove the @
.
Don't use @
to supress the error and check your logs, it is one of a few things:
Debugging is the answer.
Well, it is most likely because the headers were already sent due to whitespace. You'll never know this because you have a @
sign in front of it that stops errors from being displayed.
Generally this whitespace might be caused by another error, or it might only happen when you include a certain file.
The other possibility is that $url
is not properly formatted, or somehow the header just looks wrong to the browser. In which case the browser might choose to ignore it. Echo out the complete Header you are sending and make sure it looks right.
Finally, some browsers will stop redirecting if you have redirected too many times in a row.
The header might not be sent right away. Always use die()
after header()
.