私のdebian/Lenny上のApacheを2.2.9バージョンに更新しました。何らかの理由でエンコーディングがもう正しくありません。Apacheのアップデート後にZend関数が不正なエンコーディングを返す
私はUTF-8をすべてのマイページに使い、いくつかのAJAXを実行するために多くのjavascriptを使用しています。このエンコーディングの問題は、javascriptを台無しにし、フロントエンドで奇妙な動作を作ります。
ここでは、私のajax呼び出し時に私のバックエンドが返す例を示します:{"d": "http://my.domain.com"、 "status":true}
(私は、彼らがそれらの中にいくつかの数字と通常の疑問符と奇妙rectangeあり、あなたが変な文字を見ることを願っています)
私は返すようにApacheを強制しようとしたUTF- 8 "AddDefaultCharset UTF-8"オプションを使用してエンコードします。私は自分のコードを全く変更しませんでした。
私はこの1つを助けてください、私はもう見えるべきかわかりません。ここで
は私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/
そして、私のバーチャルホストの設定
NameVirtualHost Myip
<VirtualHost *:80>
DocumentRoot /var/www/domain.com/public
ServerName domain.com
ServerAlias *.domain.com
ServerAdmin [email protected]
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>
あなたの助けをありがとう、あなたはより多くの情報が必要な場合は私に知らせてください。 この問題を解決できることを願っています。
なぜhtmlメタタグエンコーディングを使用しないのですか? –
実際はそうです。問題はHTML側ではない。それは私のバックエンドに情報を取得するための呼び出しを行うか、エンコーディングが正しいでないいくつかのアクションを実行するときです。私のjavascriptが結果を正しく解釈するのを妨げる奇妙な文字が追加されます。 –
ここには微妙な精度があります。関数renderJSONのように私は私のajaxに奇妙な文字を追加して情報を送信するために使用しています。 if($ this-> ajax){ $ this-> renderJSON(TRUE、array( 'd' => $ redirect)); } –