Maxime Lepers
Maxime Lepers

Reputation: 59

Zend function returns with a bad encoding after apache update

I updated today my Apache on my debian/Lenny to the 2.2.9 version and for some reason the encoding is not right anymore.

I use UTF-8 on all my pages and a lot of javascript to do some ajax, I do that for the login for example. This encoding problem screw up the javascript and create weird behavior on the front end.

Here is an example of what my backend returns when I do my ajax calls : {"d":"http://my.domain.com","status":true}���������������

(I hope you will see the weird characters, they are the usual question mark and weird rectange with some numbers in them)

I tried to force apache to return UTF-8 encoding using the "AddDefaultCharset UTF-8" option. I didn't change my code at all.

Please help me on this one, I don't know where to look anymore.

Here is my 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/

And my Vhost configuration

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>

Thank you for your help and let me know if you need more information. I hope we will be able to resolve this problem.

Upvotes: 0

Views: 262

Answers (1)

Maxime Lepers
Maxime Lepers

Reputation: 59

I resolved my problem.

Actually it was the PHP version I was using that had a problem with the encoding. I uninstalled PHP and reinstalled it and it resolved my problem.

I was using 5.2.6 and updated to 5.2.7

Hope that can help someone in the future.

Upvotes: 1

Related Questions