Is it possible to setup a redirect in a PHP file which is guaranteed to work?
I want to make a call to/include a PHP script which would force a re-direct to another page. (The other page will contain a captcha and will re-direct back开发者_运维问答 if entered correctly).
I need the most reliable PHP redirect code possible, so no one can escape/avoid it. If the redirect fails then the rest of the page will be shown and that's not what I want.
The most reliable is probably issuing:
header('Location: http://example.org');
exit;
Although rare a browser might choose not to follow the redirect though and as far as I know you will not find a way of redirecting the user that is guaranteed to work if they actively seek to escape it.
Like I say though it would be a rare browser that did not recognise or accept a Location
header and a user would have to actively disable it some how. It is part of the original HTTP spec after all.
No.
A redirection can be avoided if someone is actively seeking to avoid it or is using a browser which doesn't handle it correctly.
精彩评论