LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1187|回复: 9

自建的服务器中的网页不能显示中文

[复制链接]
发表于 2003-5-8 16:14:50 | 显示全部楼层 |阅读模式
我用的是linux9.0自带的apache也就是改名后的httpd2.4.40,建了一个服务器
然后我把我从网上下下来的网页放在服务器的文档目录里面,然后用Mozilla浏览了下
http://172.27.53.100/linux/1.html (172.27.53.100是我的ip)
不过显示的都是乱码,只有在‘查看’--‘字符编码’里面改成‘简体中文(gb2312)’才可显示中文,我在其它windows机器上查看我服务器上的网页,也是乱码。
    不过我上网看其它网站的网页,就不存在这样的问题,中文显示很正常,我看了下设置,在‘查看’--‘字符编码’里面自动设制的就是‘简体中文’。而通过我服务器的网页设置却是‘西方(iso-8859-1)’
不知道为什么会这样子的,不知是不是哪儿没有设好啊?
发表于 2003-5-8 16:22:26 | 显示全部楼层

你用的是什么服务器?是apache吗?

你用的是什么服务器?是apache吗?
要是的话,在它的配制文件里,有一个应该修改的地方
那就是:
AddDefaultLanguage GB2312
就行了。
 楼主| 发表于 2003-5-8 16:32:08 | 显示全部楼层
对,我用的就是apache,不过它现改了名了,叫httpd了
哦,谢了,我去试试
 楼主| 发表于 2003-5-8 19:21:47 | 显示全部楼层
我的配制文件原来有句是:AddDefaultCharset iso-8859-1
我照黄叶兄说的把它改成了:addDefaultCharset gb2312
不过,在网页列表里的文件名可以正常显示中文了,但是只要打开列表里面的网页
网页里面还是乱码
我的配置文件里面字符相关的如下:
  #
# DefaultLanguage and AddLanguage allows you to specify the language of
# a document. You can then use content negotiation to give a browser a
# file in a language the user can understand.
#
# Specify a default language. This means that all data
# going out without a specific language tag (see below) will
# be marked with this one. You probably do NOT want to set
# this unless you are sure it is correct for all cases.
#
# * It is generally better to not mark a page as
# * being a certain language than marking it with the wrong
# * language!
#
# DefaultLanguage nl   我也改过这句,把#去了后再把nl改成下面提到的zh-tw,tw,gb2312都行不通,还是不能自动显示网页中的中文
#
# Note 1: The suffix does not have to be the same as the language
# keyword --- those with documents in Polish (whose net-standard
# language code is pl) may wish to use "AddLanguage pl .po" to
# avoid the ambiguity with the common suffix for perl scripts.
#
# Note 2: The example entries below illustrate that in some cases
# the two character 'Language' abbreviation is not identical to
# the two character 'Country' code for its country,
# E.g. 'Danmark/dk' versus 'Danish/da'.
#
# Note 3: In the case of 'ltz' we violate the RFC by using a three char
# specifier. There is 'work in progress' to fix this and get
# the reference data for rfc1766 cleaned up.
#
# Danish (da) - Dutch (nl) - English (en) - Estonian (et)
# French (fr) - German (de) - Greek-Modern (el)
# Italian (it) - Norwegian (no) - Norwegian Nynorsk (nn) - Korean (kr)
# Portugese (pt) - Luxembourgeois* (ltz)
# Spanish (es) - Swedish (sv) - Catalan (ca) - Czech(cz)
# Polish (pl) - Brazilian Portuguese (pt-br) - Japanese (ja)
# Spanish (es) - Swedish (sv) - Catalan (ca) - Czech(cz)
# Polish (pl) - Brazilian Portuguese (pt-br) - Japanese (ja)
# Russian (ru) - Croatian (hr)
#
AddCharset GB2312      .gb2312  这是我自已加的,没用
AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .et
AddLanguage fr .fr
AddLanguage de .de
AddLanguage he .he
AddLanguage el .el
AddLanguage it .it
AddLanguage ja .ja
AddLanguage pl .po
AddLanguage kr .kr
AddLanguage pt .pt
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pt-br .pt-br
AddLanguage ltz .ltz
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .se
AddLanguage cz .cz
AddLanguage ru .ru
AddLanguage tw .tw
AddLanguage zh-tw .tw
AddLanguage hr .hr
                                                                                                                                               
#
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority  en da nl et fr de el it ja kr no pl pt pt-br ltz ca es sv tw
                                                                                                                                               我把tw加到en的前面也不行
#
# ForceLanguagePriority allows you to serve a result page rather than
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
# [in case no accepted languages matched the available variants]
#
ForceLanguagePriority Prefer Fallback
                                                                                                                                               
#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#
AddDefaultCharset gb2312
                                                                                                                                               
#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets for
# the official list of charset names and their respective RFCs
#
AddCharset GB2312      .gb2312     .gb      ;这是我自已加的,也没用
AddCharset ISO-8859-1  .iso8859-1  .latin1
AddCharset ISO-8859-2  .iso8859-2  .latin2 .cen
AddCharset ISO-8859-3  .iso8859-3  .latin3
AddCharset ISO-8859-4  .iso8859-4  .latin4
AddCharset ISO-8859-5  .iso8859-5  .latin5 .cyr .iso-ru
AddCharset ISO-8859-6  .iso8859-6  .latin6 .arb
AddCharset ISO-8859-7  .iso8859-7  .latin7 .grk
AddCharset ISO-8859-8  .iso8859-8  .latin8 .heb
AddCharset ISO-8859-9  .iso8859-9  .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
                                                                                            AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5        .Big5       .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251   .win-1251
AddCharset CP866       .cp866
AddCharset KOI8-r      .koi8-r .koi8-ru
AddCharset KOI8-ru     .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8       .utf8
                                                                                                                                               
# The set below does not map to a specific (iso) standard
# but works on a fairly wide range of browsers. Note that
# capitalization actually matters (it should not, but it
# does for some browsers).
#
# See ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets
# for a list of sorts. But browsers support few.
#
AddCharset GB2312      .gb2312 .gb
AddCharset utf-7       .utf7
AddCharset utf-8       .utf8
AddCharset big5        .big5 .b5
AddCharset EUC-TW      .euc-tw
AddCharset EUC-JP      .euc-jp
AddCharset EUC-KR      .euc-kr
AddCharset shift_jis   .sjis
                                                                                                                                               
每次都要我选简体中文(gb2312)才行,我想是不是要在上面的配置里的哪一句改成gb2312才行
 楼主| 发表于 2003-5-8 19:34:46 | 显示全部楼层
哦,我在windows机子上面用http://172.27.53.100/linux/查 ... 72.27.53.100/linux/
后面的/输出来才能打开网页,否刚显示“正在查找主机www.skywx.com”(skywx是我的主机名),然后说找不到了,不知什么原因,是不是我要把主机名删了才行啊
 楼主| 发表于 2003-5-8 19:43:42 | 显示全部楼层
呵呵,怪我自已太笨了,网页列表里面的目录要用加/才能打开
就像我上面的linux目录,文件不需要的,还是请兄弟们不要为我上面的分神,还是帮看看讨论一下为什么linux服务器里面的网页不能自动显示中文呢
 楼主| 发表于 2003-5-8 19:52:35 | 显示全部楼层
唉!要说我今天没有灌水,我自已都不相信
我换了个网页打开,怪了,是中文。
就是以前那个网页死活都不肯显中文,我又试了几个网页,都行啊
神了,可能是那个网页脑子短路了。害得我好苦啊。呜呜。。。。。
那这么说的话,只要把这句改成AddDefaultCharset gb2312就大功告成了
发表于 2003-5-8 21:31:51 | 显示全部楼层
我也遇到类似的问题,这个是因为windows的Temprary Internet Files文件夹里会保存一些刚刚访问过的内容,当再次请求时就是从本地读取,故仍旧是乱码。如果清除掉该文件夹下的所有东东(删除所有脱机文件)就可以了。
 楼主| 发表于 2003-5-8 22:47:43 | 显示全部楼层
哦,原来如此。多谢兄弟解惑了
发表于 2003-5-18 15:55:52 | 显示全部楼层
有没有注意到这样一个问题:
apache2.0安装以后, 在默认配置下,日文和韩文都能正常显示, 而中文好像不论如何都不支持.
在各大linux和服务器架设的专业论坛上类似这样对apache中文的支持的贴子有很多,但本人至今尚未看到有一个得到圆满的解决方案.
如果问题是出在apache2.0本身对中文支持上, 那么我们在这里讨论如何配置httpd.conf就没有多大的意义了.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表