2012-09-23 59 views
3

嘗試登錄到管理面板時,我遇到了此錯誤。我無法理解它。無法修改Wordpress中的標題信息錯誤

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 backup 2),這似乎觸發了此問題。我使用HTML-kit工具檢查了wp.config文件的時間,並且在開始和結束時沒有可見的空白。我有:

  1. 經過從WP-config文件中的空格與HTML-Kit工具
  2. 下載並重新命名它

插入新的新鮮的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和我完全不理解這個代碼的功能也不怎麼有詳細的說明,其中以精確地放置它。有更好的建議嗎?


    主題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 . '/'; 
    
        } 
    
    } 
    
    ?> 
    
  • +1

    刪除'<?'之前的空格,它應該可以工作。 – Gumbo

    +0

    正如我所提到的,記事本++或HTML套件工具編輯器沒有前導空格,並保存在ANSI中。爲了進一步運行它,我甚至再次下載了文件,只填寫了必要的部分。 – user1692154

    回答

    4

    如果你有functions.php文件到當前主題目錄,然後執行如下成你的functions.php文件

    //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標籤。

    如果確實如此,您應該依次選擇每個字符並刪除它(按Del鍵)。然後,當您保存(Ctrl + S)文件時,它將與以前完全相同,只有沒有前導BOM。

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

    +0

    我不能得到它的工作。我沒有編程經驗。我該把它放在什麼地方? – user1692154

    +0

    添加我的答案代碼只是上面的函數get_root_directory($路徑)這一行到你的function.php文件 – GBD

    +0

    我用UTF-8的c面板代碼編輯器編輯主題文件。沒有運氣。我對這個問題感到非常沮喪。我甚至嘗試通過暫時重命名主題和插件來禁用主題和插件,以及將基本wordpress主題二十一十一增加到新的主題目錄,但錯誤依然存在。我不知道該從哪裏出發。 – user1692154

    0

    這聽起來類似的問題,我曾在其他應用程序。你在頁面輸出的任何地方看到字符?您可能會遇到字節順序標記問題。 http://en.wikipedia.org/wiki/Byte_order_mark這些取決於文件的編碼。我不記得我是如何解決這個問題的,但是試着用UTF-8保存文件?或者也許告訴你的Web服務器以某種方式,這些文件是ANSI?在頁面頂部

    <?php ob_start(); ?> 
    

    +0

    嗨,雅各和你的回覆。我無法檢測任何BOM /空格。在使用Filezilla進行傳輸時,我以前使用過HTML texk工具包和記事本++,但現在我使用UTF-8中的c面板代碼編輯器。 – user1692154

    +0

    好的。我在ANSI(1983)中打開文件時發現了BOM。但問題仍然存在,因爲我唯一可以看到的是BOM和起始行: '?php? /** * WordPressin perusasetukset。 * * T' BOM在UTF-8中不可見,我無法編輯ANSI中的文件。如何擺脫這種煩惱? – user1692154

    2

    這是WordPress中很常見的問題, 添加這一點。 快樂編碼!

    +0

    你的意思是wp-config.php文件? – user1692154

    +0

    無需編輯wp_config文件。只要把它放在頁面的頂部,在那裏你寫頭(「location:your_url」); – Gaurav

    +0

    在wordpress核心文件中編輯並不是件好事。 – Gaurav