IIS7 显示它自己的 404 消息 &CF9 消息;应该只显示它​​自己的 [英] IIS7 Displays BOTH Its Own 404 Message & CF9 Message; Should Display Just Its Own

查看:23
本文介绍了IIS7 显示它自己的 404 消息 &CF9 消息;应该只显示它​​自己的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标似乎很简单.

我希望 IIS 7.5 处理 所有 404 文件未找到请求,无论是静态还是动态 (ColdFusion 9) 内容,并将用户定向到其自定义 404 HTML 页面.

I want IIS 7.5 to handle ALL 404 File Not Found requests, whether to static or dynamic (ColdFusion 9) content, and direct users to its custom 404 HTML page.

我相信我需要的 IIS 设置是 existingReponse=R​​eplaceerrorMode=Custom 和为 404 指定的文件路径.这就是我所做的.

I believe that the IIS settings I need are existingReponse=Replace, errorMode=Custom, and a file path specified for the 404. That's what I've done.

安装 ColdFusion 10 后,它可以工作.对于 ColdFusion 9,出于某种原因,静态 IIS 404 响应和 ColdFusion 404 响应都被发送到客户端并显示.很奇怪.

With a ColdFusion 10 install, it works. With ColdFusion 9, for some reason both the static IIS 404 response AND the ColdFusion 404 response are sent to the client and displayed. Very weird.

我尝试了各种替代配置,但每种方法似乎都有一些问题.

I've tried all manner of alternate configurations, and there seems to be some problem with each approach.

为什么 IIS 无法替换 ColdFusion 的 404 消息有什么想法吗?ColdFusion 是否无法与 IIS 通信(通过适当的标头)它正在发送 404?IIS 是顽固的吗?为什么 ColdFusion 10 和 ColdFusion 9 会有所不同?

Any ideas why IIS would fail to replace ColdFusion's 404 message? Is ColdFusion failing to communicate to IIS (via the appropriate header) that it's sending a 404? Is IIS being obstinate? Why would it be different with ColdFusion 10 and ColdFusion 9?

ColdFusion 9,通过 CFAdmin

ColdFusion 9, via CFAdmin

Global Settings
- Missing Template Handler = [no path specified]

IIS 7,通过 IIS 管理器

IIS 7, via IIS Manager

Configuration Editor -> system.webServer/httpErrors

    - allowAbsolutePathWhenDelegated = false
    - defualtPath  =  [no path specified]
    - defaultResponseMode = File
    - errorMode = Custom
    - existingResponse = Replace

Configuration Editor -> system.webServer/httpErrors -> Edit Collection

    - 404 Error
        path = [DriveLetter]:inetpubwwwrootCAESglobalerrorHandling404.html
        prefixLanguageFilePath = [none specified]
        respnseMode = File
        statusCode = 404
        subStatusCode = -1
    - 403 Error
        path = [DriveLetter]:inetpubwwwrootCAESglobalerrorHandling403.html
        prefixLanguageFilePath = [none specified]
        respnseMode = File
        statusCode = 404
        subStatusCode = -1

推荐答案

这实际上应该可以解决多个有关 ColdFusion 和 IIS 7.5 的问题.在我新的运行 CF9 标准的 Win2k8 R2/64 位服务器上,这解决了双 IIS 和 CF 错误模板显示的问题,无需设置 IIS 向公众显示详细的错误消息并向客户端返回正确的错误代码浏览器.

This should actually solve more than one question/problem regarding ColdFusion and IIS 7.5. On my fresh Win2k8 R2/64-bit server running CF9 Standard, this has solved the issue of dual IIS and CF error template displays, eliminated the need to set IIS to display detailed error messages to the public and returns proper error codes to the client browser.

除非您有特定原因取消选中它,否则请在 CF 管理员的设置屏幕中选中 ColdFusion 的启用 HTTP 状态代码框,以便 CF 可以正确地将状态代码返回给 IIS(某些 404 解决方案通过取消选中此框来工作,但会丢失那些有用的标题).

Unless you have a specific reason to uncheck it, leave ColdFusion's Enable HTTP Status Codes box checked in the CF Admin's Settings screen so CF can properly return status codes to IIS (some 404 solutions work by unchecking this box at the expense of losing those useful headers).

第 1 步:
在 CF 管理器中配置缺失模板处理程序.我的对服务器来说是全局的,并保存在 ColdFusion webroot 中——它与 IIS Web 根分开,其默认位置是 c:ColdFusion9wwwroot.此全局模板为 404handler.cfm,包含以下简单代码,您可以对其进行扩展:

Step 1:
Configure a Missing Template Handler in CF Administrator. Mine is global to the server and kept in the ColdFusion webroot - which is separate from the IIS web root and whose default location is c:ColdFusion9wwwroot. This global template is 404handler.cfm and contains the following simple code, which you can expand upon:

<h1>404</h1>
<p>Page Not Found</p>
<cfheader
    statuscode="404"
    statustext="Not Found">

此时,访问您的网站并执行错误的 ColdFusion 网址:http://[domain]/bogus.cfm.您将看到 IIS 远程错误屏幕/横幅,然后是您的 ColdFusion 错误屏幕.检查标题,它是一个 404.下一步将解决双显示问题.

At this point, visit your web site and execute a bad ColdFusion url: http://[domain]/bogus.cfm. You will see both the IIS remote error screen/banner followed by your ColdFusion error screen. Check the header and it is a 404. This next step will solve the dual display problem.

第 2 步:
在单个网站的 Web 根目录下的某处创建一个本地 404 处理程序.我将此文件命名为 'local404.cfm'.它包括以下内容:

<h1>404</h1>
<p>Page Not Found (local)</p>
<!--- 
demonstrate ColdFusion is functional 
with some simple output 
--->
<cfoutput>
<p>#now()#<br>#cgi.server_name#</p>
</cfoutput>
<cfheader
    statuscode="404"
    statustext="Not Found">

转到 IIS 管理器并单击您的个人网站.单击错误页面并编辑此站点的 404 处理程序.将其设置为执行 url 并使 url '/local404.cfm' (或任何合适的路径).保存您的工作.在屏幕右侧,单击编辑功能设置并确保将其设置为本地请求的详细错误和远程请求的自定义错误页面".接下来,在 IIS 中访问 Handler Mappings 并确保您的 ColdFusion 处理程序设置为 'File' 的路径类型(此步骤可能不是解决此问题所必需的),但符合 ColdFusion 锁定指南).

Go to IIS Manager and click on your individual web site. Click on Error Pages and edit this site's 404 handler. Set it to execute a url and make the url '/local404.cfm' (or whatever path is appropriate). Save your work. On the right side of the screen, click Edit Feature Settings and make sure that it is set for 'Detailed Errors For Local Requests and Custom Error Pages for Remote Requests'. Next, while still in IIS visit Handler Mappings and ensure that your ColdFusion handlers are set for a Path Type of 'File' (this step may not be necessary to solve this issue, but is per ColdFusion Lockdown guidelines).

再次执行错误的 ColdFusion 网址:http://[domain]/bogus.cfm.这次您只看到 ColdFusion 错误屏幕.检查标头,它是 404.对非 CF 允许 URL 执行相同操作,例如 http://[domain]/bogus.htm 和一个不允许,比如http://[domain]/web.config.在所有情况下,您都应该看到本地错误模板正在执行,并发出正确的 404 标头.

Execute a bad ColdFusion url again: http://[domain]/bogus.cfm. This time you see only the ColdFusion error screen. Check the header and it is a 404. Do the same for a non-CF allowed URL such as http://[domain]/bogus.htm and a not-allowed one like http://[domain]/web.config. In all cases you should see the local error template executing, and the proper header of 404 being issued.

发生了什么?只有本地基于 IIS 的 ColdFusion 驱动的 404 模板正在执行... 一旦您在 IIS 中启用本地 ColdFusion 模板,全局 ColdFusion 模板将被有效且完全禁用.但是,它可以如图所示更换.

What is happening? Only the local IIS-based Coldfusion-driven 404 template is executing... As soon as you enable a local ColdFusion template in IIS, the global ColdFusion template is effectively and completely disabled. However it can be replaced as shown.

将上述应用到服务器上的所有网站,您就可以删除您的全局 CF 缺失模板处理程序.最好使用单个全局模板,但这种方法可以解决问题并且提供完整的功能,而不会造成安全或 SEO 问题.

Apply the above to all web sites on the server, and you can delete your global CF missing template handler. A single global template would be preferable, but this method solves the problem and gives back complete functionality without creating security or SEO issues.

这篇关于IIS7 显示它自己的 404 消息 &amp;CF9 消息;应该只显示它​​自己的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆