无法在Wordpress中修改标头信息错误 [英] Cannot modify header information error in Wordpress

查看:171
本文介绍了无法在Wordpress中修改标头信息错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试登录管理面板时,我遇到了这个错误。我无法理解它。

I am stuck with this error when trying to login to the admin panel. I can't get my head around it.

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:

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 backup 2)。我已经使用HTML-kit工具检查了wp.config文件,并且在文件的开头和结尾都没有可见的空格。我有:

I am using the latest version wordpress 3.4.2. My site seems to be working just fine but the error prevents me getting in to the login page which means I can't admin at all or uninstall the plugin (dbc backup 2) which seems to have triggered this problem. I have checked the wp.config file hunderds of times with HTML-kit tools and there is no visible whitespace at the begining nor at the end of the file. I have:


  1. 使用HTML-Kit工具检查wp-config文件中的空格

  2. 已下载并插入新的新鲜wp-config文件

  3. 通过重命名禁用插件目录

。 ..并且错误仍然存​​在

...and the error still remains

我唯一要尝试的是这个代码,有人发布在wordpress论坛上声称他已经通过插入以下代码解决了这个问题wp-config.php文件:

The only thing left for me to try is this code someone posted on wordpress forums claiming he had solved this problem by inserting the following code to the wp-config.php file:

    <?
//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而且我并不完全了解这段代码是如何运作的,也没有详细说明如何准确放置它。有什么更好的建议吗?

I am reluctant to add code as I am not familiar with html or php and I do not exactly understand how this code functions nor have detailed instructions where to place it exactly. Any better suggestions?

主题function.php文件像这样结束,我应该在哪里准确插入代码?:

Themes function.php file ends like this, where should I exactly insert the code?:

// 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 . '/';

    }

}

?>


推荐答案

如果你有当前主题的functions.php文件目录,然后执行以下操作进入你的functions.php文件

If you have functions.php file into your current theme directory, then do as below into your functions.php file

//allow redirection, even if your theme starts to send output to the browser
add_action('init', 'clean_output_buffer');
function clean_output_buffer() {
        ob_start();
}

如何删除BOM

为了删除BOM,Lafontaine建议使用免费软件实用程序XVI32,一个免费的十六进制编辑器。编辑器没有安装,你可以直接从ZIP运行EXE文件。这个过程很简单 - 只需将受影响的PHP文件(在我的情况下为wp_config.php)拖到XVI32中,它将以一个整齐的字节网格打开。然后,您应该看到文件中的前三个字节是,然后是php标记。

In order to remove the BOM, Lafontaine suggests using the freeware utility XVI32, a free hexadecimal editor. The editor doesn’t install, you can just run the EXE file right from the ZIP. The process is simple – just drag your "affected" PHP file (in my case wp_config.php) into XVI32 and it will open in a neat byte-grid. Then, you should see that the very first three bytes in the file are "" followed by php tag.

如果确实如此,你应该依次选择每个字符并删除它(按Del键)。当您保存(Ctrl + S)文件时,它将与以前完全相同,只是没有前导BOM。

If this is indeed the case, you should select each character in turn and just delete it (press the Del key). When you then save (Ctrl+S) the file, it will be completely the same as it used to be, only without the leading BOM.

完整文章链接:
http://blog.scribz .net / 2010/12 / windows-live-writer-wordpress-unicode-bom-error /

这篇关于无法在Wordpress中修改标头信息错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆