简体   繁体   中英

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

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:

最后一个RewriteRule的结果

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

结果应为原样,或者最后一个RewriteRule被注释掉时

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

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM