Zend函数在apache更新后返回时编码错误

Zend函数在apache更新后返回时编码错误,apache,zend-framework,encoding,character-encoding,Apache,Zend Framework,Encoding,Character Encoding,今天我在debian/Lenny上将Apache更新为2.2.9版本,由于某种原因,编码不再正确 我在所有页面上都使用UTF-8,并使用大量javascript来执行一些ajax,例如,我在登录时就是这样做的。这个编码问题会使javascript出错,并在前端产生奇怪的行为 下面是一个我的后端在执行ajax调用时返回的示例:{“d”:http://my.domain.com“,“状态”:true}��������������� (我希望你能看到这些奇怪的字符,它们是常见的问号和带有数字的奇怪的矩

今天我在debian/Lenny上将Apache更新为2.2.9版本,由于某种原因,编码不再正确

我在所有页面上都使用UTF-8,并使用大量javascript来执行一些ajax,例如,我在登录时就是这样做的。这个编码问题会使javascript出错,并在前端产生奇怪的行为

下面是一个我的后端在执行ajax调用时返回的示例:{“d”:http://my.domain.com“,“状态”:true}���������������

(我希望你能看到这些奇怪的字符,它们是常见的问号和带有数字的奇怪的矩形)

我试图使用“addDefaultCharsetUTF-8”选项强制apache返回UTF-8编码。我根本没有更改代码

请帮帮我,我不知道该去哪里找了

这是我的apache2.conf

ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15

<IfModule mpm_prefork_module>
StartServers          5
MinSpareServers       5
MaxSpareServers      10
MaxClients          150
MaxRequestsPerChild   0
</IfModule>

<IfModule mpm_worker_module>
StartServers          2
MaxClients          150
MinSpareThreads      25
MaxSpareThreads      75 
ThreadsPerChild      25
MaxRequestsPerChild   0
</IfModule>

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>

DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn

Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined

Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
ServerRoot”/etc/apache2“
LockFile/var/lock/apache2/accept.lock
PidFile${APACHE_PID_文件}
超时300
继续
MaxKeepAliveRequests 100
暂停15分钟
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
StartServers 2
MaxClients 150
Minspare25
MaxSpareThreads 75
螺纹预裂25
MaxRequestsPerChild 0
用户${APACHE\u RUN\u User}
组${APACHE\u RUN\u Group}
AccessFileName.htaccess
命令允许,拒绝
全盘否定
默认类型文本/纯文本
主机名查询
ErrorLog/var/log/apache2/error.log
日志级别警告
Include/etc/apache2/mods enabled/*.load
Include/etc/apache2/mods enabled/*.conf
Include/etc/apache2/httpd.conf
Include/etc/apache2/ports.conf
日志格式“%v:%p%h%l%u%t\%r\“%>s%b\”%{Referer}i\“\”%{User-Agent}i\\”vhost\u
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\\“%%{User Agent}i\\”组合
日志格式“%h%l%u%t\%r\”%>s%b”通用
日志格式“%{Referer}i->%U”Referer
日志格式“%{User agent}i”代理
CustomLog/var/log/apache2/other_vhost_access.log vhost_组合
包括/etc/apache2/conf.d/
已启用Include/etc/apache2/站点/
和我的Vhost配置

NameVirtualHost Myip
<VirtualHost *:80>
DocumentRoot /var/www/domain.com/public
ServerName domain.com
ServerAlias *.domain.com

ServerAdmin dev@domain.net

RequestHeader edit Host: ^([^.]+)\.my\.domain\.com my.domain.com early
RequestHeader edit Host: ^([^.]+)\.api\.domain\.com api.domain.com early
RequestHeader edit Host: ^([^.]+)\.partners\.domain\.com partners.domain.com early
RequestHeader edit Host: ^([^.]+)\.admin\.domain\.com admin.domain.com early

AddOutputFilterByType DEFLATE text/html text/plain text/xml

<Location />
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|swf)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

<Directory /var/www/domain.com/public>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php
</Directory>

ErrorLog /var/log/apache2/domain_error.log
CustomLog /var/log/apache2/domain_access.log combined
</VirtualHost>
NameVirtualHost Myip
DocumentRoot/var/www/domain.com/public
ServerName域名.com
ServerAlias*.domain.com
服务器管理员dev@domain.net
RequestHeader编辑主机:^([^.]+)\.my\.domain\.com my.domain.com早期
RequestHeader编辑主机:^([^.]+)\.api\.domain\.com api.domain.com早期
RequestHeader编辑主机:^([^.]+)\.partners\.domain\.com partners.domain.com早期
RequestHeader编辑主机:^([^.]+)\.admin\.domain\.com admin.domain.com早期
AddOutputFilterByType DEFLATE text/html text/plain text/xml
#插入过滤器
SetOutputFilter放气
#Netscape 4.x有一些问题。。。
浏览器匹配^Mozilla/4 gzip纯文本/html
#网景4.06-4.08还有一些问题
浏览器匹配^Mozilla/4\.0[678]无gzip
#MSIE伪装成网景,但它很好
#BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
#注意:由于Apache 2.0.48之前的mod_setenif中存在错误
#上面的正则表达式不起作用。您可以使用以下命令
#获得所需效果的变通方法:
浏览器匹配\bMSI[E]!没有gzip!仅限gzip文本/html
#不要压缩图像
setEnvifLocase请求\u URI\
\(?:gif | jpe | g | png | swf)$无gzip不变
#确保代理不会提供错误的内容
标头附加变量用户代理env=!不要改变
选项如下符号链接
允许超越所有
选项如下符号链接多视图
允许超越所有
命令允许,拒绝
通融
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则!\。(js | ico | gif | jpg | png | css)$/index.php
ErrorLog/var/log/apache2/domain\u error.log
CustomLog/var/log/apache2/domain\u access.log组合
谢谢您的帮助,如果您需要更多信息,请告诉我。 我希望我们能够解决这个问题。

我解决了我的问题

实际上,我使用的PHP版本在编码方面有问题。 我卸载了PHP并重新安装了它,它解决了我的问题

我使用的是5.2.6并更新为5.2.7


希望这能对将来的人有所帮助。

为什么不使用html元标记编码?事实上我是这样做的。问题不在HTML方面。当我调用后端来检索信息或执行某些操作时,编码不正确,最后添加了一些奇怪的字符,阻止我的javascript正确解释结果。看起来我用来将信息发送回ajax的renderJSON函数添加了一些奇怪的字符。if($this->ajax){$this->renderJSON(TRUE,数组('d'=>$redirect));}