0

为了解决 IE8 兼容性问题,我想在不更改应用程序源代码的情况下更改 REST 服务响应的内容类型。

我正在尝试使用 mod_rewrite 规则来做到这一点:

RewriteCond %{HTTP_USER_AGENT} .*MSIE\s8.*
RewriteRule /app/name(.*) - [T=application/new.content.type+xml]

此规则适用于静态内容,但不适用于 REST 服务响应。

我将 Apache 2.2.3 与 JBoss 5.1 一起使用。

在 Apache 上,我在 httpd.conf 文件中配置了 RewriteRule,在日志文件中查看:

(3) applying pattern '/app/name(.*)' to uri '/app/name/events/service'
(4) RewriteCond: input='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR     2.0.50727)' pattern='.*MSIE\\s8.*' => matched
(2) remember /app/name/events/service to have MIME-type 'new.content.type'
(1) pass through /app/name/events/service
(1) force filename service to have MIME-type 'new.content.type'

在 JBoss 上,我尝试在引擎和服务器级别配置 RewriteValve,在日志文件中我可以看到:

2014-11-19 10:56:34,442 DEBUG [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]] Rewrote /app/name/events/services as /app/name/events/services with rule pattern /app/name(.*)

规则似乎已应用,但我的 REST 服务内容类型保持不变。

任何人都可以提出一个原因,或进一步调试的下一步吗?

非常感谢。

4

0 回答 0