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

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

问题描述

我的目标似乎很简单。

My goal seems simple.

我希望IIS 7.5处理所有 404 File Not Found请求,无论是静态还是动态(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 = Replace errorMode = 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]:\inetpub\wwwroot\CAES\global\errorHandling\404.html
        prefixLanguageFilePath = [none specified]
        respnseMode = File
        statusCode = 404
        subStatusCode = -1
    - 403 Error
        path = [DriveLetter]:\inetpub\wwwroot\CAES\global\errorHandling\403.html
        prefixLanguageFilePath = [none specified]
        respnseMode = File
        statusCode = 404
        subStatusCode = -1


推荐答案

这应该实际上解决关于ColdFusion和IIS 7.5的多个问题/在我新鲜的Win2k8 R2 / 64位服务器运行CF9标准,这已经解决了双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管理器中配置缺少的模板处理程序。 Mine对服务器是全局的,并保存在ColdFusion webroot中 - 它与IIS web根目录分开,其默认位置为c:\ColdFusion9\wwwroot。这个全局模板是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:\ColdFusion9\wwwroot. 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。它包含以下内容:

Step 2:
Create a local 404 handler somewhere under the web root of an individual web site. I named this file 'local404.cfm'. It consists of the following:

<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中访问处理程序映射,并确保您的ColdFusion处理程序设置为'文件'的路径类型(此步骤可能不必解决这个问题,但是根据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 URL: http:// [domain] /bogus.cfm 。这一次你只看到ColdFusion错误屏幕。检查标头,它是一个404.对于非CF 允许的网址,例如 http:// [domain] / bogus。 htm / strong>和不允许的类似 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 Message;应该显示它自己的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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