Recipe 12.5 Setting the Content-Type According to Browser Capability
Problem
You want to set
Content-Type
headers differently for different browsers, which may render the
content incorrectly otherwise.
Solution
Check the Accept headers with
RewriteCond and then set the
Contend-Type header with a T
flag:
RewriteCond "%{HTTP_ACCEPT}" "application/xhtml\+xml"
RewriteCond "%{HTTP_ACCEPT}" "!application/xhtml\+xml\s*;\s*q=0+(?:\.0*[^0-9])"
RewriteRule . - [T=application/xhtml+xml;charset=iso-8859-1]
Discussion
Different browsers tend to deal with content differently and
sometimes need a nudge in the right direction. In this example, for
browsers that specify (using the HTTP_ACCEPT
header) that they prefer XHTML content, we want to send a
Content-Type header specifying that the content we
are sending fulfills that requirement.
The T (Type) flag sets the
Content-Type for the response.
See Also
|