Reputation: 63636
@header('Location: ' . $uri);
But it only seldom happens,what's the problem?
Upvotes: 0
Views: 229
Reputation: 20601
The header might not be sent right away. Always use die()
after header()
.
Upvotes: 1
Reputation: 61567
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.
Upvotes: 1
Reputation: 28386
Don't use @
to supress the error and check your logs, it is one of a few things:
Debugging is the answer.
Upvotes: 3
Reputation: 798626
Perhaps your script is sending some output before it for some reason. Remove the @
.
Upvotes: 2