php发送404头问题
一个简单的问题。我知道如何在 php 中发送 404 标头,但是当我这样做时,页面仍然继续加载内容。在这种情况下,我还必须使用 die() 来终止脚本。我有一个定制的自制 cms,速度非常快并且非常适合我的网站。但由于某种原因,谷歌索引了该网站的不正确链接,这很可能是由于一些不再存在的旧代码造成的。发生的情况是,诸如“/AWebDirectory/AndAnother/function.fopen/”之类的目录已附加到url,即
www.someurl.com/index.php/AWebDirectory/AndAnother/function.fopen/
这不会抛出404,因为index.php存在,但由于目录结构,CSS和内容没有加载。任何帮助表示赞赏。
A quick question. I know how to send a 404 header in php but when I do the page still continues to load content. In this case must I kill the script also with die(). I have a custom home made cms which is very fast and well suited to my site. But for some reason google has indexed an improper link to the site that was most likely due to some old code that no longer exists. What is happening is that directories such as "/AWebDirectory/AndAnother/function.fopen/" has gotten appended to the url i.e.
www.someurl.com/index.php/AWebDirectory/AndAnother/function.fopen/
This is not throwing a 404 as index.php exists but the css and stuff is not loading due to the directory structure. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要退出脚本,否则它会继续运行。这是正常的。我不是 100% 确定,但我认为您可能正在寻找重定向:
尝试使用 404 标头,然后重定向到您的自定义 404 页面。这应该能让你启动并运行。
You need to exit the script or it will just keep going. This is normal. I'm not 100% sure, but I think you might be looking for a redirect:
Try using both the 404 header, and redirect to your custom 404 page. That should get you up and running.