Workaround issue of Helicon Ape .htaccess RewriteRule from modifying Content Type

245 Views Asked by At

Issue:

Using .htaccess in IIS7.5 using Helicon Ape with the last RewriteRule which when left uncommented drops the Content-Type from the Response Headers as viewed by Chrome inspector (see example screen captures below). This occurs to the /flex2gateway/ path which should produce a Content-Type of application/x-amf:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*/index.cfm/(.*)$ [NC]
RewriteRule ^.*/index.cfm/(.*)$ ./rewrite.cfm/$1 [NS,L]
RewriteCond %{REQUEST_URI} !^.*/(flex2gateway|jrunscripts|cfide|cfformgateway|cffileservlet|railo-context|lucee|files|images|javascripts|miscellaneous|stylesheets|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$) [NC]
RewriteRule ^(.*)$ ./rewrite.cfm/$1 [NS,L]

Results from the last RewriteRule:

Results from the last RewriteRule

Results as they should be or when the last RewriteRule is commented out

Results as they should be or when the last RewriteRule is commented out

I have tried numerous workarounds including adding the following but nothing has resolved the issue:

RewriteRule ^flex2gateway/$ [NS,T=application/x-amp,L]
2

There are 2 best solutions below

0
Micah Githens On BEST ANSWER

I finally figured it out and of course it was a simple fix!

Just add jakarta| to the RewriteCond pattern:

RewriteCond %{REQUEST_URI} !^.*/(jakarta|flex2gateway|jrunscripts|cfide|cfformgateway|cffileservlet|railo-context|lucee|files|images|javascripts|miscellaneous|stylesheets|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$) [NC]

ColdFusion 10 is now using /jakarta/isapi_redirect.dll to process the flex2gateway path.

3
Jannes Botis On

Looks like the folder flex2gateway actually exists and when you try to get the "/flex2gateway/" path, it tries to return the directory listing.

Try to add a rule for this:

RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} ^.*/(flex2gateway|jrunscripts|cfide|cfformgateway|cffileservlet|railo-context|lucee|files|images|javascripts|miscellaneous|stylesheets)(/?)$[NC]
RewriteRule ^(.*)$ ./rewrite.cfm/$1 [NS,L]

which will redirect to "./rewrite.cfm/$1" script. Change this to your preferred target.