malformed header from script. Bad header的解決方法

 轉自:http://soige.blog.51cto.com/512568/325409
malformed header from script. Bad header的解決方法
今天配了CGI服務器,打開CGI報錯:
[Wed Jun 02 13:57:21 2010] [error] [client 192.168.0.1] malformed header from script. Bad header=Hello,World!: index.cgi
[Wed Jun 02 13:57:21 2010] [error] [client 192.168.0.1] malformed header from script. Bad header=Hello,World!: index.cgi
[Wed Jun 02 13:57:21 2010] [error] [client 192.168.0.1] malformed header from script. Bad header=Hello,World!: index.cgi
 
    在服務器上用perl支持文件是正確的,權限也有了,後面在網上查到是文件頭有問題。CGI文件第一句一定要先定義內型,然後跟着是一個新空行,在下來就是主程序了,由於我在定義內型後沒有輸出文件頭及換行,直接就是主程序,所以一才導致上面出現的錯誤。
    CGI不執行,APACHE錯誤日誌:Premature end of script headers,或 malformed header from script. Bad headerXXX,這種情況,還是檢查一下CGI輸出的第一句話是啥。應該是形如:
       Content-type:text/html\n\n
       注意:聲明好Content-type後要輸出兩個空行。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章