我有一个在 WordPress 上运行的网站。在这个站点的文档根目录中,我有一个目录,我在其中测试与我的 WordPress 安装无关的 PHP 脚本。我注意到每当我需要或包含一个确实存在的文件时,我都会收到 404。如果我注释掉 require 语句,一切都很好。起初,这是因为语法错误。但是我清理了它,并且不再在 error_log 文件中得到任何东西。是什么赋予了?
编辑:在我的主要 error_log: 中找到了这个malformed header from script. Bad header=X-UA-Compatible: ide.php
。我在其他 Apache 服务器上从来没有遇到过这个问题。
以下是有问题的脚本:
ide.php
<?php
require_once 'config.php';
if (isset($_SESSION['username'])) {
if (isset($_POST['command'])) {
if ($_POST['session'] == '@') {
session_destroy();
header('Location: /area51/ide.php');
} else {
echo 'None';
}
} else {
$smarty->assign('version', shell_exec("/home1/tylercro/local/python3/bin/python3 -c \"import sys;print('Python', sys.version)\""));
$smarty->display('ide.tpl');
}
} else {
if (isset($_POST['username']) && isset($_POST['password'])) {
if ($_POST['username'] == 'user' && $_POST['password'] == 'password') {
$_SESSION['username'] = $_POST['username'];
}
header('Location: /area51/ide.php');
} else {
$smarty->display('ide-login.tpl');
}
}
?>
配置文件
<?php
error_reporting(E_ALL);
session_start();
if (!headers_sent()) {
header('X-UA-Compatible: chrome=1');
header('Content-Type: text/html; charset=UTF-8');
}
require_once 'Smarty-3.1.8/Smarty.class.php';
$smarty = new Smarty();
$smarty->setTemplateDir('Smarty-3.1.8/templates/');
$smarty->setCompileDir('Smarty-3.1.8/templates_c/');
$smarty->setCacheDir('Smarty-3.1.8/cache/');
$smarty->setConfigDir('Smarty-3.1.8/configs/');
?>