【问题标题】:Rewrite issue with ColdFusion and IISColdFusion 和 IIS 的重写问题
【发布时间】:2013-07-10 14:07:20
【问题描述】:

我们在 IIS7.5 上有以下重写规则(在 James Moberg 回答后重写):

<rule name="Anything else to the event handler" enabled="true" stopProcessing="true">
  <match url="^(.*)$" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{PATH_INFO}" pattern="^.*(/index.cfm/).*$" negate="true" />
  </conditions>
  <action type="Rewrite" url="/index.cfm/{R:1}" appendQueryString="true" logRewrittenUrl="true" />
</rule>

但是,它从不将/{R:1} 放在其后面。它只是转到/index.cfm。我们需要实际获取引用变量,因为我们在 ColdFusion (10) 脚本中使用了它。我们想要的示例 url 重写:

发件人:http://www.my-site.com/this.is.a.test/another.test

收件人:http://www.my-site.com/index.cfm/this.is.a.test/another.test

有人知道为什么不这样做吗? (快速提示:执行正确的 URL 时可能会出现 ColdFusion 错误,但我认为这不会导致重写问题?)

注意,当您在浏览器中尝试相同的操作(禁用规则)时,它确实有效 - 只是没有重写规则。使用重写规则,CF 中的cgi.PATH_INFO 变量返回空字符串。

另外,IIS 确实说它在日志中将 URL 重写为 index.cfm/this.is.a.test/another.test,这很奇怪。

【问题讨论】:

    标签: iis coldfusion rewrite


    【解决方案1】:

    您应该添加条件以防网站托管图像、js、css 等。您也不想重写任何可能包含 CFM 的 URl。

    这些是我们正在使用的条件:

    <conditions>
        <add input="{SCRIPT_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{SCRIPT_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{PATH_INFO}" pattern="^.*(/index.cfm/).*$" negate="true" />
    </conditions>
    

    【讨论】:

    • 谢谢!明天我会在 oir 测试版上试试这个。我们已经在这条规则前面有其他重写规则来处理 css/js。但我一定会看看添加 index.cfm 作为条件会做什么。
    • 好吧,我试过了,但它似乎对我原来的问题没有帮助。有什么想法吗?
    • 虽然它现在可以使用 301 重定向,但这当然不是我想要的。
    • 如果我启用失败的请求跟踪,我也没有收到任何错误。工作得很好。
    【解决方案2】:

    问题是我们昨天应用了新的更新 11 后需要重新做 Coldfusion 10 的配置工具。它现在正在工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-15
      • 2019-10-26
      • 2012-06-18
      • 2016-01-09
      • 2012-05-15
      • 2016-11-03
      • 1970-01-01
      • 2015-10-09
      相关资源
      最近更新 更多