Saturday, July 6, 2013

#WordPress Cannot modify Headers Error

Warning: Cannot modify header information - headers already sent by (output started at /home/kkk/public_html/wp-config.php:1) in /home/kkk/public_html/wp-includes/pluggable.php on line 877

This  error will come up if debugging is enabled and can crash your website.
It makes reference to a file and to the line of code below, but as we'll see this error has nothing to do with either the file or the line.

#877) header("Location: $location", true, $status);

- The main solution we can find online and on the WordPress site is related to the php file tags, particularly making sure they they are correctly opened and closed the begging and ending of the file, respectively.

- Other resources mention the need for the ob_start() call in order to start an URL redirection.
//allow redirection with wp_redirect, even if my plugin starts to send output to the browser
add_action('init', 'do_output_buffer');
function do_output_buffer() {

- In my case, and thanks to this post, it turns down that this is a problem in wp-config.php itself, related to the text format of the file.
So, in order to fix this, all we have to do is open a basic text editor such as notepad and then save the file specifically indicating the ANSI Coding, instead of any other.
This error is specially common when using Windows systems to submit files to a Unix-based web server.

No comments:

Post a Comment