开发者

php send 404 header problems

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/f开发者_运维技巧unction.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.


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:

<?php

/**
 * @see http://php.net/manual/en/function.header.php
 */

header("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

Try using both the 404 header, and redirect to your custom 404 page. That should get you up and running.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜