【问题标题】:FW/1 SES and IIS RewritesFW/1 SES 和 IIS 重写
【发布时间】:2014-02-20 14:00:33
【问题描述】:

我刚刚开始使用 FW/1,我只是想让事情正常运行,但对 SES 网址不太满意。

所以在 Application.cfc 我打开 SES 网址并删除 index.cfm 我有:

generateSES = true
SESOmitIndex = true

在我的main.cfc 中,我有两个项目defaultseconditem

public void function default( rc ) {
    rc.when = now();
    variables.fw.service( 'formatter.longdate', 'today' );
}

public void function seconditem( rc ) {
    rc.when = now();
    variables.fw.service( 'formatter.longdate', 'today' );
}

main.cfc 中的每个项目都有视图,web.config 文件中有此重写规则

<rule name="Insert index.cfm" stopProcessing="true">
    <match url="^(.*)$" ignoreCase="false" />
    <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.cfm/{PATH_INFO}" appendQueryString="true" logRewrittenUrl="true" />
</rule>

问题来了:

当我转到 http://dev.dev/main/default - 它调用 main.default

当我转到 http://dev.dev/main/seconditem - 它调用 main.default 而不是 main.seconditem

如果我将index.cfm 添加回来:

当我转到http://dev.dev/index.cfm/main/default - 它调用main.default

当我转到http://dev.dev/index.cfm/main/seconditem - 它调用main.seconditem

查看我的 IIS 日志,URL 正在被重写以包含 index.cfm

2014-02-19 23:13:44 GET /index.cfm/main/default - 80
2014-02-19 23:13:53 GET /index.cfm/main/seconditem - 80

所以根据 IIS 日志告诉我重写工作正常,为什么当我转到没有 index.cfm 的 url 时,它总是转到 main.default

我也尝试过使用不同的控制器,其中:

http://dev.dev/users/default - 转到main.default

但是:

http://dev.dev/index.cfm/users/default - 转到users.default

IIS 日志显示这两个请求:

2014-02-19 23:20:47 GET /index.cfm/users - 80
2014-02-19 23:21:37 GET /index.cfm/users - 80

任何想法都将不胜感激

【问题讨论】:

    标签: iis coldfusion url-rewriting fw1


    【解决方案1】:

    这是我在 FW/1 项目中使用的重写规则

    <rule name="Imported Rule 1" stopProcessing="true">
            <match url="^(.*)$" />
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" pattern="^((?!\.).)*$|(\.cfm)$" />
                <add input="{URL}" matchType="Pattern" pattern="/(assets|scratch|remote|index.cfm|extensions)" ignoreCase="true" negate="true" />
            </conditions>
            <action type="Rewrite" url="/index.cfm/{R:1}" />
    </rule>
    

    第二个&lt;add&gt; 块用于列出我不想重写的目录或文件。

    【讨论】:

    • 嗨,斯科特,不幸的是,这似乎对我不起作用。除了http://dev.dev/ 之外,我只是得到一个 404 Not Found 错误。所以去http://dev.dev/main/defaulthttp://dev.dev/main/seconditem都会抛出404。我在你的规则中添加了logRewrittenUrl="true",IIS日志显示GET /main/seconditem - 80所以它根本没有添加/index.cfm/
    • 好的,我已经弄清楚发生了什么,只用了 2 天 :) 安装上次更新后,我没有重新运行 ColdFusion Web 服务器配置工具。所以我这样做了,现在一切正常。感谢您发布重写规则。
    猜你喜欢
    • 1970-01-01
    • 2014-10-15
    • 2022-11-10
    • 2019-07-03
    • 2011-05-23
    • 2018-12-06
    • 1970-01-01
    • 1970-01-01
    • 2012-07-15
    相关资源
    最近更新 更多