以下是简化的.htaccess文件:
RewriteEngine On
RewriteRule ^index$ index.php在我本地的lamp服务器上,一切正常,但在生产服务器上有一些问题。myurl/index只返回空白屏幕,不解析php。当需要的文件被直接访问(myurl/index.php)时,它工作得很好。
我注意到,只有在所需的文件中包含wordpress头文件(wp/wp-blog-header.php)时,才会出现这个问题。经过进一步的研究,我发现wp()运行时会返回空白屏幕。已为wordpress启用错误报告,并且日志文件中没有条目。
有人知道为什么会这样吗?
发布于 2009-08-08 17:37:38
谢谢你,Josh,你的脚本很有用。我找到了解决方案。我不知道为什么,但是如果使用了重写的url,内容就会被缓冲。
<?php while (@ob_end_flush()); ?>在文件的开头有帮助。
发布于 2009-08-08 14:31:38
我知道你说错误报告是启用的,但我想我会问:它是如何启用的? 99%的时间我都看到了你所描述的,因为错误报告是禁用的。
下面是一个快速测试,看看它是否是PHP错误。以下代码将在发生PHP错误时向您发送电子邮件。我经常做的是将其放入一个名为"errorhandler.php“的文件中,并将该文件包含在其他PHP文件中以启用此错误处理程序。你需要调整它来适应你的场景...例如,更改"YOURDOMAIN“和"YOUREMAIL”:-)
<?php
function reportError($errorNumber, $errorString, $errorFile = false, $errorLine = false, $errorContext = false)
{
global $php_errormsg,$config,$system;
$domainName = $_SERVER['HTTP_HOST'];
$longDate = date("F j, Y g:i:s A O");
$errorContext_ht = '<pre>'.htmlspecialchars(print_r($errorContext,true)).'</pre>';
$backtrace = debug_backtrace();
//$backtrace_ht = eval("return print_r(\$backtrace,true);");
$backtrace_ht = '<pre>'.htmlspecialchars(print_r($backtrace,true)).'<pre>';
$url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'N/A';
$errorNumber_human = '';
switch($errorNumber)
{
case E_ERROR: $errorNumber_human = ' (E_ERROR)'; break;
case E_NOTICE: $errorNumber_human = ' (E_NOTICE)'; break;
case E_WARNING: $errorNumber_human = ' (E_WARNING)'; break;
case E_PARSE: $errorNumber_human = ' (E_PARSE)'; break;
case E_CORE_ERROR: $errorNumber_human = ' (E_CORE_ERROR)'; break;
case E_CORE_WARNING: $errorNumber_human = ' (E_CORE_WARNING)'; break;
case E_COMPILE_ERROR: $errorNumber_human = ' (E_COMPILE_ERROR)'; break;
case E_COMPILE_WARNING: $errorNumber_human = ' (E_COMPILE_WARNING)'; break;
case E_USER_ERROR: $errorNumber_human = ' (E_USER_ERROR)'; break;
case E_USER_WARNING: $errorNumber_human = ' (E_USER_WARNING)'; break;
case E_USER_NOTICE: $errorNumber_human = ' (E_USER_NOTICE)'; break;
}
$error_env = compact('errorNumber', 'errorString', 'errorFile', 'errorLine', 'errorContext');
$html = <<<END_OF_HTML_MESSAGE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<style type="text/css">
body {
color: #000;
background-color: #fff;
font-family: Verdana, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
font-variant: normal;
}
</style>
<body>
<div id="content">
<div id="header">
<h1>Website Error Report</h1>
<h2>{$domainName}</h2>
<h3>{$longDate}</h2>
</div>
<div id="errorReport">
<h2>Error Summary:</h2>
<dl>
<dt>Error Code</dt>
<dd>{$errorNumber}{$errorNumber_human}</dd>
<dt>Error String</dt>
<dd>{$errorString}</dd>
<dt>URL</dt>
<dd><a href="{$url}">{$url}</a></dd>
<dt>Error File</dt>
<dd>{$errorFile} line {$errorLine}</dd>
<dt>User Info</dt>
<dd><a href="http://ws.arin.net/whosi/?queryinput={$_SERVER['REMOTE_ADDR']}">{$_SERVER['REMOTE_ADDR']}</a>
using {$_SERVER['HTTP_USER_AGENT']}</dd>
<dt>Referrer</dt>
<dd><a href="{$referrer}">{$referrer}</a></dd>
<dt>PHP Error Message</dt>
<dd>{$php_errormsg}</dd>
<dt>Context</dt>
<dd>$errorContext_ht</dd>
<dt>Backtrace</dt>
<dd>$backtrace_ht</dd>
</dl>
</div>
</div>
</body>
</body>
</html>
END_OF_HTML_MESSAGE;
$subject = "{$domainName} Error!";
$headers .="From: weberrors@YOURDOMAINHERE\r\n";
$headers .="Content-Type: text/html; charset=\"iso-8859-1\"\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
mail('YOUREMAILHERE',$subject,chunk_split(base64_encode($html)),$headers);
}
function __error($errorNumber, $errorString, $errorFile = false, $errorLine = false, $errorContext = false)
{
$fatal = false;
$msg = '';
// #108 ignore IIS SSL errors
if ($errorString == 'fgets(): SSL: fatal protocol error')
return false;
switch($errorNumber)
{
case E_NOTICE:
// We don't care about notices or warnings. Pass off to PHP.
return false;
case E_USER_NOTICE:
$msg = '';
break;
case E_USER_WARNING:
case E_WARNING:
$msg = <<< END_OF_HTML
<p style="_errorWarning">There were potential errors processing your request. Our staff has been notified.
Please make sure your request was properly fulfilled. If you need assistance please contact us.</p>
END_OF_HTML;
break;
case E_USER_ERROR:
case E_CORE_ERROR:
case E_ERROR: $fatal = true;
default:
$msg = <<< END_OF_HTML
<h1>Error</h1>
<h2>Your request could not be completed</h2>
<p>We're sorry but your request could not be completed. We have automatically composed an error report
which has been sent to the server administrator. Please try your request again, or email the staff and
request assistance.</p>
END_OF_HTML;
break;
}
echo $msg;
reportError($errorNumber, $errorString, $errorFile, $errorLine, $errorContext);
if($fatal)
{
$obLevel = @ob_get_level();
for($i=0;$i<$obLevel;$i++)
ob_end_flush();
exit();
}
return true;
}
set_error_handler('__error');https://stackoverflow.com/questions/1246605
复制相似问题