【发布时间】:2012-09-23 10:48:41
【问题描述】:
我在尝试登录管理面板时遇到此错误。我无法理解它。
Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxx/public_html/wordpress/wp-config.php:1) in /home/xxxxxx/public_html/wordpress/wp-includes/pluggable.php on line 881
pluggable.php 881:
function wp_redirect($location, $status = 302) {
global $is_IIS;
$location = apply_filters('wp_redirect', $location, $status);
$status = apply_filters('wp_redirect_status', $status, $location);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = wp_sanitize_redirect($location);
if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location", true, $status);
}
endif;
我正在使用最新版本的 wordpress 3.4.2。我的网站似乎运行良好,但该错误阻止我进入登录页面,这意味着我根本无法管理或卸载似乎触发了此问题的插件(dbc 备份 2)。我已经用 HTML-kit 工具检查了 wp.config 文件数百次,并且在文件的开头和结尾都没有可见的空格。我有:
- 使用 HTML-Kit 工具检查 wp-config 文件中的空格
- 下载并插入新的 wp-config 文件
- 通过重命名禁用插件目录
...错误仍然存在
我唯一可以尝试的是有人在 wordpress 论坛上发布的代码,声称他通过将以下代码插入到 wp-config.php 文件中解决了这个问题:
<?
//dont use header function in wordpress-wp_signup.php
global $domain;
global $path;
//change urlnew variable as per requirment
$urlnew = "http://".$domain.$path."/wp-admin/admin.php;
echo "<script>";
echo "location = '$urlnew';";
echo "</script>";
echo $urlnew;
?>
我不愿添加代码,因为我不熟悉 html 或 php,而且我不完全了解此代码的功能,也没有详细说明将其准确放置在何处。有更好的建议吗?
Themes function.php 文件这样结束,我应该在哪里插入代码?:
// include custom widget
$temp_root = get_root_directory('include/plugin/custom-widget/custom-blog-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/custom-blog-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/custom-port-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/custom-port-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/custom-port-widget-2.php');
include_once($temp_root . 'include/plugin/custom-widget/custom-port-widget-2.php');
$temp_root = get_root_directory('include/plugin/custom-widget/popular-post-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/popular-post-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/contact-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/contact-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/flickr-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/flickr-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/twitter-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/twitter-widget.php');
// get the path for the file ( to support child theme )
function get_root_directory( $path ){
if( file_exists( STYLESHEETPATH . '/' . $path ) ){
return STYLESHEETPATH . '/';
}else{
return TEMPLATEPATH . '/';
}
}
?>
【问题讨论】:
-
删除
<?之前的前导空格,它应该可以工作。 -
正如我提到的,notepad++ 或 HTML 工具包工具编辑器没有前导空格,并保存在 ANSI 中。为了进一步运行它,我什至再次下载了文件并只填写了必要的部分。
标签: php wordpress http-headers configuration-files pluggable