我建议使用 404 而不是 403,因为 403 证明存在值得入侵的东西。
index.php
<?php
define('isdoc',1);
include('includes/include.sqlfunctions.php');
?>
include.sqlfunctions.php(或其他包含文件)
<?php
if(isdoc !== 1) {
header('HTTP/1.1 404 Not Found');
echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head>";
echo "<body>\n<h1>Not Found</h1>\n<p>The requested URL ".$_SERVER['REQUEST_URI']." was not found on this server.</p>\n";
echo "<hr>\n".$_SERVER['SERVER_SIGNATURE']."\n</body></html>\n";
exit;
}
?>