简体   繁体   English

修改内容类型导致Helicon Ape .htaccess RewriteRule的变通办法问题

[英]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). 在IIS7.5中将Helicon Ape与最后一个RewriteRule一起使用IIS7.5中的.htaccess,如果不加注释,则会从响应标头中删除Content-Type(由Chrome检查器查看)(请参见下面的示例屏幕截图)。 This occurs to the /flex2gateway/ path which should produce a Content-Type of application/x-amf: 这发生在/ flex2gateway /路径中,该路径应生成application / x-amf的Content-Type:

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的结果:

最后一个RewriteRule的结果

Results as they should be or when the last RewriteRule is commented out 结果应为原样,或者最后一个RewriteRule被注释掉时

结果应为原样,或者最后一个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| 只需添加jakarta| to the RewriteCond pattern: RewriteCond模式:

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. ColdFusion 10现在正在使用/jakarta/isapi_redirect.dll处理flex2gateway路径。

Looks like the folder flex2gateway actually exists and when you try to get the "/flex2gateway/" path, it tries to return the directory listing. 看起来文件夹flex2gateway实际上存在,并且当您尝试获取“ / flex2gateway /”路径时,它将尝试返回目录列表。

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. 它将重定向到“ ./rewrite.cfm/$1”脚本。 Change this to your preferred target. 将此更改为您的首选目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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