FW / 1 SES和IIS重写

时间:2014-02-20 14:00:33

标签: iis coldfusion url-rewriting fw1

我刚刚开始使用FW / 1而我只是想让事情顺利进行,但是对于SES网址没有太多运气。

所以在Application.cfc我正在关闭SES网址并删除index.cfm我有:

generateSES = true
SESOmitIndex = true

在我的main.cfc我有2件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的网址时,它总是转到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

任何想法都会非常感激

1 个答案:

答案 0 :(得分:3)

这是我在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>

第二个<add>块用于列出我不想重写的目录或文件。