Mobile app version of vmapp.org
Login or Join
Jessie594

: Append encoding information to HTTP response headers I have an old web application (not maintained anymore) of which a small part is still needed; this is displayed in iframes. Unfortunately,

@Jessie594

Posted in: #Apache #ContentEncoding

I have an old web application (not maintained anymore) of which a small part is still needed; this is displayed in iframes.

Unfortunately, the old application uses ISO-8859-1 encoding (which it doesn't declare; it simply sends Content-Type: text/html), while the new one (of course) uses UTF-8. Thus, since the encoding of the iframe contents is not specified, UTF-8 is expected, and thus several characters look wrong.

The VirtualHost of the old application does some rewriting to a JBoss application:

RewriteRule ^/(.*) localhost:9080/ [L,P]


I'm able to edit this VirtualHost (while nobody will touch the application itself anymore); how would I add the encoding information?

E.g., for all contents with a textual content type which lack encoding information (naked Content-Type: text/html), append ; charset: ISO-8859-1.
Any simple code snippet? Thank you!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Jessie594

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly868

The HTTP header you need to add is Content-Type: text/html; charset: ISO-8859-1.



You can add FilesMatch and other directives within the Apache <VirtualHost> declaration:

<VirtualHost>
# other directives here such as DocumentRoot
<FilesMatch ".(htm|html|php)$">
AddDefaultCharset ISO-8859-1
Header always set Content-Type "text/html; charset: ISO-8859-1"
</FilesMatch>
<FilesMatch ".(css)$">
AddDefaultCharset ISO-8859-1
Header always set Content-Type "text/css; charset: ISO-8859-1"
</FilesMatch>
<FilesMatch ".(js)$">
AddDefaultCharset ISO-8859-1
Header always set Content-Type "text/javascript; charset: ISO-8859-1"
</FilesMatch>
RewriteRule ^/(.*) localhost:9080/ [L,P]
</VirtualHost>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme