在加载文档之前,PHP 标头位置会更改停止搜索爬虫


will php header location change before the document is loaded stop search crawlers?

通过要求用户设置会话,并且如果不使用 php 标头重定向他们,我是否可以安全地阻止搜索引擎爬虫看到我的页面内容?

我不明白他们会怎么做,但我想保持积极的态度。

好的爬虫会跟随重定向,看不到页面内容。恶意机器人仍会抓取该页面。这就是为什么您应该始终在发送重定向标头后使用 exit() 结束脚本的执行。

header('Location: /login.php');
exit();