问题
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:
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;
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:
- Checked the whitespaces from wp-config file with HTML-Kit tools
- Downloaded and inserted new fresh wp-config file
- Disabled the plugins directory by renaming it
...and the error still remains
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;
?>
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?
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 . '/';
}
}
?>
回答1:
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();
}
HOW to remove BOM
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.
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.
Complete Article Link: http://blog.scribz.net/2010/12/windows-live-writer-wordpress-unicode-bom-error/
回答2:
this is very common problem in wordpress, Add this :
<?php ob_start(); ?>
on top of the page. Happy coding!!
回答3:
This sounds similar to an issue I have had in other applications. Do you see the characters 
anywhere in the page output? You might be having issues with byte order markers. http://en.wikipedia.org/wiki/Byte_order_mark These are dependent on the encoding of the file. I don't remember exactly how I addressed this issue but try saving the file in UTF-8? Or perhaps tell your web server somehow that the files are ANSI?
来源:https://stackoverflow.com/questions/12551689/cannot-modify-header-information-error-in-wordpress