LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Directive in Apache for autoswitching of charset encoding. (https://www.linuxquestions.org/questions/linux-server-73/directive-in-apache-for-autoswitching-of-charset-encoding-677854/)

MheAd 10-20-2008 01:10 PM

Directive in Apache for autoswitching of charset encoding.
 
I'm building a custom httpd.conf file, meaning "from the scratch" and I don't want to have unnecessary stuff activated. This is also a good learning experience, to know what you exactly need for certain things.
I've been trying to figure out this thing whole day by looking through Apache documentation without getting anywhere. Of course, there are no problems with this if one uses default httpd.conf file (shipped with Fedora 8) because there everything needed is added.

Here is the thing...
If I for instance create a simple file, with no MIME-stuff, no formatting whatsover, with Swedish character, using vim, and save it as html file it will be identified as UTF-8 document by FireFox, and it will switch automatically to the proper encoding and the characters will be shown properly - this is when I use the default Apache configuration. If I use my own (as I mentioned, don't really know which directives are needed so I obviously don't have them added) - the characters are shown in ugly way and my FireFox remains set to the default ISO-8859-1, so I need to manually switch to UTF-8 to get the proper characters.

I first thought it had to do with combination of AddLanguage sv sv. stuff but after closer research, from what I understood, it only concernes html files that do content mime-headers. I was experimenting with AddDefaultCharacter and different kinds of things - no use. I also thought negotiation module had something to do with it - activated it - no use.

So basically, I need to figure out what directives I need to put in httpd.conf that will notify my browser to switch to correct encoding. I hope I've made myself clear and you guys can help me out.

Here is how my Apache conf looks like.

Code:

Listen 80
User apache
Group apache
ServerRoot /etc/httpd
Options +FollowSymlinks

Include conf.d/php.conf

LoadModule      mime_module            modules/mod_mime.so
TypesConfig /etc/mime.types

LoadModule      dir_module              modules/mod_dir.so
DirectoryIndex index.html index.htm

LoadModule      autoindex_module        modules/mod_autoindex.so

Options +Indexes
IndexOptions FancyIndexing ScanHTMLTitles FoldersFirst SuppressSize DescriptionWidth=*

HeaderName HEADER.html

IndexIgnore = "*~"

LoadModule      alias_module    modules/mod_alias.so
Alias  /icons/ /var/www/icons/
 
AddIconByType /icons/layout.gif text/html
AddIconByType /icons/text.gif text/plain
AddIconByType /icons/generic.gif text/*
AddIconByType /icons/image2.gif image/*
AddIconByType /icons/sound1.gif audio/*
AddIconByType /icons/movie.gif video/*
AddIconByType /icons/ps.gif application/postscript
AddIconByType /icons/pdf.gif application/pdf

AddIcon /icons/dir.gif  "^^DIRECTORY^^"
AddIcon /icons/back.gif ".."
 
DefaultIcon /icons/ball.gray.gif

AddAltByType "HTML file" text/html
AddAltByType "Plain text" text/plain
AddAltByType "Text" text/*
AddAltByType "Static image" image/*
AddAltByType "Audio" audio/*
AddAltByType "Video" video/*
AddAltByType "PostScript" application/postscript
AddAltByType "PDF" application/pdf

AddAlt  "Directory" "^^DIRECTORY^^"
AddAlt  "Go Back" ".."

LoadModule log_config_module modules/mod_log_config.so

LogFormat "%h %l %u %t \"%r\" %>s %b" clf

ErrorLog logs/error_log

LogLevel info
 
HostNameLookups off

LoadModule authz_host_module modules/mod_authz_host.so

LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule auth_digest_module modules/mod_auth_digest.so

NameVirtualHost *
<snip> (Virutal hosts left out in this post - I don't add anything special there except for Document root).


Thanks in advance!
M.


All times are GMT -5. The time now is 05:00 AM.