1

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]
Micah
  • 1,221
  • 17
  • 42
  • I tried posting to http://www.helicontech.com/community/Helicon_Ape-8.html but their community login isn't working right now. – Micah Apr 19 '18 at 17:17
  • 1
    Seems like the response is blank also because content length is 0? What is that last rule for? Have you looked at the error logs? Also I would suggest you enable rewrite logs and provide the same with the question https://stackoverflow.com/questions/9632852/how-to-debug-apache-mod-rewrite – Tarun Lalwani Apr 24 '18 at 06:15

2 Answers2

2

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.

Micah
  • 1,221
  • 17
  • 42
0

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.

Jannes Botis
  • 11,154
  • 3
  • 21
  • 39
  • "/flex2gateway/" URL is not a file, nor a directory. It's a value intercepted by a servlet filter defined within ColdFusion in this case CF10. Also, the response body is empty when the last rewrite is uncommented. – Micah Apr 24 '18 at 22:27
  • @Micah I thought I got it :(, try adding "index.cfm" to your exclude rules, |rewrite.cfm|index.cfm). I think it gets redirected to it when nothing it matched. Try also swapping the rules, though I doubt this will solve your problem. – Jannes Botis Apr 25 '18 at 15:39
  • 1
    Sorry you weren't quite able to come up with the solution but thanks for your great attempts! They encouraged me to keep trying. =) – Micah Apr 25 '18 at 17:29