htaccess and utf-8

xmsmmgrs

New member
Jul 6, 2008
41
0
0
www.jspromotion.com
I have this code only in my htaccess file:

Code:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

The problem is that the UTF-8 formatting is gone. How can I fix this? If I remove the htaccess file UTF-8 characters are back..
 


set default_charset in php.ini to utf-8

or (if php as apache module) in .htacces

php_value default_charset utf-8

or, in each php file

ini_set("default_charset","utf-8");

or, in each php file

header('Content-type: text/html; charset="utf-8"');

or, in each html file

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> ...
 
Now I have it like this:
Code:
php_value default_charset utf-8
AddType application/x-httpd-php .php .htm .html
..still not working.


EDIT:
I managed to fix it with
Code:
ForceType 'text/html; charset=UTF-8'

.. but my php scripts in html are no longer working..
 
Last edited:
Unfortunately it seems that only..
Code:
ForceType 'text/html; charset=UTF-8'

is adding the UTF-8 charset but with this I cannot use php code in my htmls..

Why can't you add default_charset=utf-8 in your php.ini? Even the crappiest shared hosts usually allow custom php.ini

The reason you can't get it to work is that php is now handling the output of php, htm, and html files but utf-8 is not set as php's default charset.

If you have access to your php.ini, change

Code:
default_charset =

to

Code:
default_charset = utf-8

If you can't do that, try this in your .htaccess

Code:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset utf-8

Don't use ForceType, that's not how it's used.
 
I have added a php.ini file with
Code:
default_charset = utf-8

in it but nothing changed. I suppose the php.ini files is not read by the server.. I suppose I'll have to redo the site in php.
 
I have added a php.ini file with
Code:
default_charset = utf-8

in it but nothing changed. I suppose the php.ini files is not read by the server.. I suppose I'll have to redo the site in php.

You need to contact your host and tell them what you are trying to do.

It's hard for me to tell you what to do when I don't know what your setup is.

If your host can't help you get this set up in less than 5 minutes, find a new host.