是否可以在 PHP 文件中设置保证正常工作的重定向?
我想调用/包含 PHP 脚本,这将强制重定向到另一个页面。 (另一个页面将包含验证码,如果输入正确,将重定向回来)。
我需要最可靠的 PHP 重定向代码,因此没有人可以逃脱/避免它。如果重定向失败,则将显示页面的其余部分,而这不是我想要的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最可靠的可能是发布:
虽然很少有浏览器可能选择不遵循重定向,但据我所知,如果用户主动寻求逃避重定向,您将找不到一种保证有效的重定向用户的方法。
就像我说的,虽然很少有浏览器无法识别或接受
Location
标头,但用户必须以某种方式主动禁用它。毕竟它是原始 HTTP 规范的一部分。The most reliable is probably issuing:
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.