iis - Coldfusion - 避免特定文件的 IIS 404.0 错误并改为手动路由

标签 iis coldfusion routes http-status-code-404 coldfusion-10

我正在使用 coldfusion 10 和 iis 7.5,并尝试为我的项目创建一个避免使用查询字符串的自定义路由。

例如,以下网址:

www.myTestWebsite.com/subfolder1/subfolder2/

应该从存在于根文件夹中的 router.cfm 文件传递​​,然后基于网站域(在本例中为/subfolder1/subfolder2/)之后的字符串,coldfusion 将决定显示什么以及如何显示。

除了一件事,我设法使一切正常。如果/subfolder1/subfolder2/路径中不存在 index.cfm(或 .html,或任何默认文件),IIS 将显示 404.0 错误。但是,如果创建文件夹结构并在其中添加一个空的 index.cfm 文件,路由将按预期工作,忽略该空的 index.cfm 并根据我已实现的逻辑继续前进。

有没有办法(通过 CF Administrator、IIS、htaccess 或任何其他方式)避免检查该文件是否存在并抛出 404.0,而是允许我通过我的 route.cfm 处理它?<​​/p>

最佳答案

我在 web.config 中使用重写:

<rule name="wvcms" patternSyntax="Wildcard" stopProcessing="true">
    <match url="*" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="/route.cfm?cmspath=/{R:1}" />
</rule>

关于iis - Coldfusion - 避免特定文件的 IIS 404.0 错误并改为手动路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41369112/

相关文章:

iis - 您可以在 IIS 中托管 ServiceStack Web 应用程序吗?

sql-server - ORM中如何处理历史表?

sql - 空字符串查询的 Coldfusion 查询

ruby-on-rails - 基于不同于 ID 的东西的 Rails Route

asp.net - IIS 中未调用 Application_Start

asp.net - 在 IIS 上使用 Http 管道进行 Rest

asp.net - 如何让 Visual Web Developer 使用 IIS,而不是 ASP.NET 开发服务器?

ColdFusion 组件从错误的路径启动

javascript - AngularJS 使用 Express Server 进行路由

c# - 路由捕获出错