howto: Server - header: change character encoding rev 7 oct 2021 How to modify HTTP headers using the .htaccess file > example | info | tools | more ....................................................... example: ............................. change character set! # Basically, you want utf-8 for all text files. #%% THIS WORKS for me: #%% THIS DOESN'T WORK: AddDefaultCharset utf-8 AddCharset UTF-8 .css .html .inc .js .php .txt IndexOptions Charset=UTF-8 ............................. history of what i tried: Header set content-type "text/html; charset=utf-8" # (Must be double-quotes) Also added in that block: AddCharset UTF-8 .html .txt .css .php .inc But i don't know if it's doing anything [30 oct 2018] BUT it turned out that setting, changed all files to text/html -- so .txt files were being displayed as one long line. Kept trying things back and forth, ended up with deleting the IfModule and Header set Using AddCharset UTF-8 .html .txt .css .php .inc seems to work. https://httpd.apache.org/docs/2.4/mod/mod_mime.html#addcharset Also tried AddDefaultCharset utf-8 which seemed like would be the best solution, and at first thought it worked, but maybe something was just cached. nowork. https://httpd.apache.org/docs/2.4/mod/core.html#adddefaultcharset ....................................................... info - server default character set It turns out that on A2Hosting, iWFhosting (and possibly on other hosting) the apache server is sending ISO-1899-1 (whyyyy????) I initially tried setting meta charset in html, but learned that this does not override the character set sent by the server. Apparently WordPress takes care of this, (which is why i was confused before and didn't follow up for a long time) -- when i load a WordPress page i see correct character set in W3c tool and in Ffx Dev Tools (below). ....................................................... tools: * Check internationalization (i18n) info in a web document https://validator.w3.org/i18n-checker/ * Check server http header output Firefox Developer Tools -> Network tab -> Click on the item you wish to examine the headers for https://stackoverflow.com/questions/33974595/in-firefox-how-do-i-see-http-request-headers-where-in-web-console https://developer.mozilla.org/en-US/docs/Tools * See the meta tags: Page Info (right-click on the page, View Page Info) (you will also see the "Text Encoding" there, whcih is coming from the server header.) https://stackoverflow.com/questions/33974595/in-firefox-how-do-i-see-http-request-headers-where-in-web-console ....................................................... more: ............................. example of basics of modifying apache headers: Header set Animal cow Header set Animal monkey Header append Animal camel Animal header is first set to cow. But because the next header option is also set, the Animal header is reset to monkey. Lastly, camel is appended to the Animal header. This generates an HTTP response header that resembles the following: HTTP/1.1 200 OK Date: Tue, 24 Jun 2014 15:23:33 GMT Server: Apache Animal: monkey, camel .......................... how-tos: * How to modify HTTP headers using .htaccess files using Header set ... A2Hosting KB [undated, retr 30 oct 2018] https://www.a2hosting.com/kb/developer-corner/apache-web-server/modifying-http-headers This one worked for me [30 oct 2018] * Setting charset information in .htaccess W3C [feb 2016] https://www.w3.org/International/questions/qa-htaccess-charset#endlinks using AddCharset UTF-8 .html This one didn't work for me [30 oct 2018] But, is good explanation of HTTP headers etc. * Checking HTTP Headers W3C [mar 2016] https://www.w3.org/International/questions/qa-headers-charset.en .......................... documentation: * Apache Module mod_include Apache 2.2 Documentation https://httpd.apache.org/docs/2.2/mod/mod_headers.html * Apache: The Definitive Guide (O'Reilly) https://docstore.mik.ua/orelly/linux/apache/ _______________________________________________________ begin 30 oct 2018 -- 0 --