Apache的自定义404页面,返回404错误 [英] Apache custom 404 page that returns 404 error
问题描述
我有我的阿帕奇(404.php)的自定义404错误页面,它工作正常,但如果有人或任何搜索引擎请求 /404.php
页,服务器返回 200(OK)
,因为页面确实存在。
I have a custom 404 error page on my apache (404.php) and it works normally, but if someone or any search engine requests the /404.php
page, the server returns 200 (OK)
, because the page actually exists.
我已经把禁止:/404.php
我的的robots.txt
文件,以$ P $从索引该页面pvent谷歌,但我想回到404,包括这个页面的请求。
I have already put the Disallow: /404.php
on my robots.txt
file to prevent Google from indexing that page, but I'd like to return 404, including to this page request.
有没有办法也返回404当有人达到 404.php
直接?
Is there a way to also return 404 when someone reaches the 404.php
directly?
推荐答案
我刚刚刮起这件事真的很快:
I just whipped this up really quickly:
<?
header("HTTP/1.1 404");
echo "ERROR"; // Put the contents of your 404 page here.
?>
我检查在Chrome,这将在头返回404 code,让你写你想在页面的其余部分不管。只要把头
功能页面的开始。
这篇关于Apache的自定义404页面,返回404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!