iT邦幫忙

0

OpenWebmail登入首頁顯示亂碼

大家好,我的OpenWebmail登入首頁顯示亂碼,但登入後就可正常顯示
請問要如何修改?懇請幫忙指教,灰熊甘蝦.
OpenWebmail登入首頁http://220.228.242.172/cgi-bin/openwebmail/openwebmail.pl

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
14
逮丸逮丸
iT邦大師 1 級 ‧ 2010-11-05 19:20:23
最佳解答

回應raytracy

raytracy提到:
AddDefaultCharset UTF-8

這個語法是會讓「說明」的那個big5的網頁,
也變成以 utf8 來呈獻。

至於您用:

raytracy提到:
# telnet 220.228.242.172 80
Trying 220.228.242.172...

其回應當然是 iso-8859-1
如果您用 firefox 的 Web Developer 的 information -> View Response Headers

<pre class="c" name="code">Response Headers - http://220.228.242.172/cgi-bin/openwebmail/openwebmail.pl

Date: Fri, 05 Nov 2010 10:00:36 GMT
Server: Apache/2.2.6 (Fedora)
Pragma: no-cache
Cache-Control: no-cache,no-store
Content-Length: 6061
Content-Type: text/html; charset=utf-8

200 OK

回應的是utf8並沒有問題,
那是因為 openwebmail 會看browser有送出接受哪些字元碼變數,
再利用 Live HTTP Headers
可看到:

<pre class="c" name="code">GET http://220.228.242.172/cgi-bin/openwebmail/openwebmail.pl HTTP/1.1
Host: 220.228.242.172
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-tw,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Proxy-Connection: keep-alive
Referer: http://ithelp.ithome.com.tw/question/10058379?tag=hp.all
Cache-Control: max-age=0

接受UTF-8,所以openwebmail會回應utf8的頁頁出來,
而telnet丟過去的query,
並沒有像瀏覽器提供這麼多的環境變數,
所以openwebmail只丟出iso-8859-1的英文網頁。

我猜測的真正問題所在
原問題的網頁,
不管切成big5或utf-8都無法正常顯示,
而該頁的「登入」、「說明」的字是正常,
所以我猜可能是 template 裡檔案傳壞的關係。

請透過以下來測試:

<pre class="c" name="code">cd /網頁目錄/cgi-bin/openwebmail/etc/templates/zh_TW.UTF-8
$ file login.template
# 看看那個會秀出登入畫面的版型檔案是否是:
login.template: UTF-8 Unicode HTML document text

再用 less login.template 看看裡面的中文是否正常。
當然要確認 shell 的環境變數是:
$ env |grep LANG
LANG=zh_TW.UTF-8
且終端機程式也是以utf8來呈現,
才看得出該檔。

同時也看看 zh_TW.Big5 裡的中文,
是否是正常顯示,
當然也要把上述的環境改成Big5的相關變數。

再試該IP,果然有開FTP,
所以造成的原因,
可能是把中文檔以 ascii 的模式傳,
所以傳壞而造成 template 的中文成亂碼,
而其他在 cgi-bin/openwebmail/etc/lang 裡面的詞彙檔是正常的,
所以才會使 登入、說明 等字樣正常顯示。

解決方式
把 cgi-bin/openwebmail/etc/templates/zh_TW.UTF-8 裡的檔案重傳一次,
確認用 binary 模式傳才不會傳壞。

其實,如果是用 ssh 來遠端下載原始檔,
解壓、編輯檔案……也不大會有FTP傳壞的問題。

iamapo iT邦新手 5 級 ‧ 2010-11-05 22:40:58 檢舉

大大的說法非常接近我目前的狀況,只是我是用WinSCP+SSH來傳輸檔案並沒有使用FTP,阿我cgi-bin/openwebmail/etc/templates/zh_TW.UTF-8裡的檔案沒有備份,要去那裡找原始檔來重傳呢? Thsnks so much.

http://www.openwebmail.org/openwebmail/download/current/openwebmail-current.tar.gz
如果可以的話,先用 ssh 的 client,
最常用且中文沒問題的是 pietty 連進去,
看看 login.template 這檔的內容。

而要抓那openwebmail的原始檔,
就用 wget 上述網址就抓下在linux裡了,
不需抓到windows後解開又傳到linux上…
最近這部電影 社群網戰 對白裡,
還出現用 wget、apache 耶…
場景背後也有一疊 Oreilly 的書,
只是看不清書名…

iamapo iT邦新手 5 級 ‧ 2010-11-08 16:09:29 檢舉

嗯..依照大大的說明下載重傳檔案再用pietty+vi編輯檔案後就恢復正常顯示網頁了.

4
csk
iT邦高手 1 級 ‧ 2010-11-05 13:38:06

可以參考此篇,可以解決您的問題
http://blog.xuite.net/jyoutw/xtech/19385176

iamapo iT邦新手 5 級 ‧ 2010-11-05 14:11:52 檢舉

3Q!那裡面的設定跟我的一樣,但我的首頁還是亂碼,殘念~

8
Ray
iT邦大神 1 級 ‧ 2010-11-05 15:56:00

大哥, 您的 apache httpd.conf 需要修改:

Ray iT邦大神 1 級 ‧ 2010-11-05 16:01:49 檢舉

這是您的 apache 所回應的 Header:

<pre class="c" name="code"># telnet 220.228.242.172 80
Trying 220.228.242.172...
Connected to adsl-220-228-242-172.nh.sparqnet.net (220.228.242.172).
Escape character is '^]'.
HEAD /cgi-bin/openwebmail/openwebmail.pl HTTP/1.0

HTTP/1.1 200 OK
Date: Fri, 05 Nov 2010 07:54:29 GMT
Server: Apache/2.2.6 (Fedora)
Pragma: no-cache
Cache-control: no-cache,no-store
Content-length: 6277
Connection: close
Content-Type: text/html; <strong>charset=iso-8859-1</strong>

Connection closed by foreign host.
Ray iT邦大神 1 級 ‧ 2010-11-05 16:01:57 檢舉

這是正常應該回應的 header:

<pre class="c" name="code"># telnet www.raytracy.com 80
Trying 60.250.68.55...
Connected to www.raytracy.com (60.250.68.55).
Escape character is '^]'.
HEAD http://mail.raytracy.com HTTP/1.0

HTTP/1.1 200 OK
Date: Fri, 05 Nov 2010 07:55:29 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sun, 12 Jul 2009 15:27:43 GMT
ETag: "a5c750-69-d8bed9c0"
Accept-Ranges: bytes
Content-Length: 105
Connection: close
Content-Type: text/html; <strong>charset=UTF-8</strong>
Content-Language: zh_TW.UTF-8

Connection closed by foreign host.

至於為何您寫的 META tag 無效? 可能是因為被 httpd.conf 給覆寫掉了....
請參考小弟的 httpd.conf 內容:

<pre class="c" name="code"><VirtualHost 60.250.00.00:80>
    ServerName  mail.abcdef.com
    ServerAdmin dingsneyou@gmail.com
    <strong>AddDefaultCharset UTF-8</strong>
    VirtualDocumentRoot /var/www/cgi-bin/openwebmail
    Alias /data /var/www/data
</VirtualHost>
Ray iT邦大神 1 級 ‧ 2010-11-05 16:04:20 檢舉

抱歉, 請將上面的<strong>和</strong>兩個多餘的tag都忽略掉....我不知道不能這樣用粗體字....

我要發表回答

立即登入回答