0

To work around a IE8 compatibility issue, I would like to change the content-type of a REST service response without changing my application source code.

I'm trying to do this with a mod_rewrite rule:

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

This rule works for static content, but not for REST service responses.

I'm using Apache 2.2.3 with JBoss 5.1.

On Apache, I've configured the RewriteRule in the httpd.conf file and in the log file see:

(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'

On JBoss, I've tried configuring the RewriteValve at the Engine and Server level, and in the log file I can see:

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(.*)

The rules appear to be applied, but my REST service content-type remains the same.

Could anyone suggest a reason why, or next steps to debug this further?

Many thanks.

awbp
  • 1
  • 1
  • `mod_rewrite` will not modify downstream responses. Look at using `mod_headers` instead and use `Header add` or `Header edit`: http://httpd.apache.org/docs/2.4/mod/mod_headers.html#header – arco444 Nov 19 '14 at 13:11
  • Thanks for your help @arco444. Looking at the documentation you are absolutely right, and I've been able to change other response headers using mod_header. Unfortunately we're using Apache 2.2.3, and it seems changes to the Content-Type with mod_header were not supported until 2.2.12. Is there another way of doing this? – awbp Nov 19 '14 at 17:08

0 Answers0