我想显示状态代码410,而是显示状态代码500.任何人都可以解释原因吗?
我正在使用IIS7和ColdFusion 9.这是我的代码:
<cfheader statuscode="410" statustext="Gone" />
<cfinclude template="../cgi-bin/file_not_found.cfm">
<cfabort>
这是我的application.cfc文件:
<cfcomponent output="No">
<cfinclude template="f/login.cfm" >
<!--- <cfinclude template="f/security.cfm"> --->
<cfset this.clientmanagement=true>
<cfset this.sessionmanagement="yes">
<cfset this.name="UL">
<cfset this.clientstorage="cookie">
<cfset this.setclientcookies="true">
<cffunction name="OnSessionStart">
<!--- 1111 --->
<!--- set defualt buyer session anyway! --->
<cfset SetDefaultBuyer()>
<cfset SetDefaultSeller()>
<!--- define session and client mylist --->
<cfset session.mylist="">
<!--- <cfif isdefined("client.mylist")><cfset session.mylist=client.mylist><cfelse><cfset session.mylist=""><cfset client.mylist=""></cfif> --->
<!--- trying to login as user --->
<cf_LoginCookies>
<cfif FindNoCase('pa_',CGI.PATH_TRANSLATED) AND ( NOT ISDefined("session.user.status")) >
<cflocation addtoken="No" url="#Application.URL#/p_login/login_form.cfm">
</cfif>
</cffunction>
<cffunction name="OnApplicationStart">
<cfinclude template="including/global_variables.cfm">
</cffunction>
<cffunction name="onRequestStart" returnType="boolean">
<!---
<cfif CGI.REMOTE_ADDR IS "81.218.200.52">
<cfelse>
<cfoutput><br> <br> <br>
<h2 align="center">Sorry,<br>
We are in process of maintenance.<br>
Please try at 10:00 AM<br>
Now is #Timeformat(now())#</h2></cfoutput>
<cfabort>
</cfif>
--->
<!--- 2222 --->
<!--- Neged atacks --->
<cfparam name="CGI.QUERY_STRING" default="222">
<cfif FindNoCase('Declare',CGI.QUERY_STRING)>
<cfabort>
</cfif>
<cfif Len(CGI.QUERY_STRING) GT 400>
<cfabort>
</cfif>
<!--- im menase lirot MyUL bli lihiot LogIn --->
<cfif FindNoCase('pa_',CGI.PATH_TRANSLATED) AND ( NOT ISDefined("session.user.status")) AND ( NOT ISDefined('form.type') )>
<cflocation addtoken="No" url="#Application.URL#/p_login/login_form.cfm">
</cfif>
<cfreturn True>
</cffunction>
<cfif CGI.HTTP_HOST IS not "192.168.1.223">
<cffunction name="onError">
<cfargument name="Except" required=true/>
<!--- Log all errors in an application-specific log file. --->
<!--- define message --->
<cfif isdefined('except.cause.cause.message')>
<cfset message=except.cause.cause.message>
<cfelseif isdefined('except.cause.message')>
<cfset message=except.cause.message>
<cfelse>
<cfset message=''>
</cfif>
<!--- define template --->
<cfif isdefined('except.cause.tagcontext')>
<cfset template=except.cause.tagcontext[1].template>
<cfset line=except.cause.tagcontext[1].line>
<cfelse>
<Cfset template=''>
<Cfset line=''>
</cfif>
<!--- define second template --->
<cfif arraylen(except.cause.tagcontext) gt 1>
<cfset template= template & ',' & except.cause.tagcontext[2].template>
<cfset line=line & ',' & except.cause.tagcontext[2].line>
<cfelse>
</cfif>
<!--- define third template --->
<cfif arraylen(except.cause.tagcontext) gt 2>
<cfset template= template & ',' & except.cause.tagcontext[3].template>
<cfset line=line & ',' & except.cause.tagcontext[3].line>
<cfelse>
</cfif>
<cfset text="Message: #message# , template:#template# , line:#line#">
<!--- define sql --->
<cfif isdefined('except.cause.sql')>
<cfset text=text & ' , sql:' & except.cause.sql>
</cfif>
<cflog file="MyAppLog" type="error" text="#text# ,client_ip: #cgi.REMOTE_ADDR# , url:#cgi.HTTP_URL#,ref:#cgi.HTTP_REFERER#">
<cfinclude template="/including/error.cfm">
<!--- <cflocation addtoken="false" url="#application.url#/including/error.cfm?message=#message#&template =#template#&line=#line#">
---> </cffunction></cfif>
<cffunction name="onRequest" returnType="boolean">
<cfargument name="targetPage" type="String" required=true/>
<cfinclude template="f/security.cfm">
<cfinclude template="#Arguments.targetPage#">
<cfreturn True>
</cffunction>
<!---
<cferror type = "request"
template = "../including/error.cfm"
mailto = "dtpozner@gmail.com"> --->
<cffunction name="onRequestEnd" returnType="boolean">
<cfreturn True>
</cffunction>
</cfcomponent>
这是我的web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="C page detailed">
<match url="^(.*)/(.*)-(.*)/cc_(.*)_s(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:4}&cat_id={R:5}&manuf={R:2}& model={R:3}" />
</rule>
<rule name="C page less detailed">
<match url="/cc_(.*)_s(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}" />
</rule>
<rule name="C Pages">
<match url="/cc_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/c_page/index.cfm?id={R:1}" />
</rule>
<rule name="B Page Pnumbers" stopProcessing="true">
<match url="/bb_(.*)_pn(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/c_index.cfm?cat_id={R:1}&pnumber={R:2}" />
</rule>
<rule name="B Pages">
<match url="/bb_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/c_index.cfm?cat_id={R:1}" />
</rule>
<rule name="TM Guide B Pages">
<match url="/tmm_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/cat_view.cfm?cat_id={R:1}" />
</rule>
<rule name="TMGuide C Page">
<match url="/tmc_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/model.cfm?model_id={R:1}" />
</rule>
<rule name="T&M-Buying-Guide" stopProcessing="true">
<match url="^T&M-Buying-Guide" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="tm_guide/index.cfm" />
</rule>
<rule name="Home Page">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/homepage/index.cfm" />
</rule>
<rule name="A Page Pnumbers">
<match url="/aa_(.*)_pn(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/m_index.cfm?main_id={R:1}&pnumber={R:2}" />
</rule>
<rule name="A Pages">
<match url="/aa_(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="category/m_index.cfm?main_id={R:1}" />
</rule>
<rule name="GogglePageModeID">
<match url="/gm_model_id(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}" />
</rule>
<rule name="GoogleModelManufCat">
<match url="/gmm_model(.*)_manuf(.*)_cat(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}&manuf={R:2}&cat={R: 3}" />
</rule>
<rule name="old b_pages" stopProcessing="true">
<match url="^b(\d+?)p(\d+?)pr(\d+?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="category/c_index.cfm?cat_id={R:1}&pnumber={R:2}&old=1" />
</rule>
<rule name="old c_pages" stopProcessing="true">
<match url="^c(\d+?)s(\d+?)-(.*?)_(.*?)\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}&manuf={R:3}& model={R:4}&old=1" />
</rule>
<rule name="old c page no model" stopProcessing="true">
<match url="^c(\d+?)s(\d+?)-(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="/c_page/index.cfm?id={R:1}&cat_id={R:2}&manuf={R:3}& old=1" />
</rule>
<rule name="old b_tb_pages" stopProcessing="true">
<match url="^b-(.*?)pn(\d+?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="tm_guide/cat_view.cfm?cat_id={R:1}&old=1" />
</rule>
<rule name="old c_tb_pages" stopProcessing="true">
<match url="^c-(.*?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="tm_guide/model.cfm?model_id={R:1}&old=1" />
</rule>
<rule name="old b_model_page" stopProcessing="true">
<match url="^b_model_mf(.*?)_mo(.*?)_pn(.*?)-.*\.htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="CustomResponse" statusCode="410" statusReason="Removed" statusDescription="Removed" />
</rule>
<rule name="old b_manuf_sec_all" stopProcessing="true">
<match url="^cgi-bin/a_dinamic/b_manuf_sec_all.cfm(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http:www.used-line.com" appendQueryString="false" />
</rule>
<rule name="result.cfm" stopProcessing="true">
<match url="^cgi-bin/a_dinamic/result.cfm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="list_of_categories/categories.cfm" />
</rule>
<rule name="old b model">
<match url="^.*_.*_m(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}" />
</rule>
<rule name="old b model mfr cid">
<match url="^.*_.*_2m(.*?)_2mnf(.*?)_2cid(.*?).htm" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="model/model_index.cfm?model_id={R:1}&manuf={R:2}&cat={R: 3}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
答案 0 :(得分:2)
像Seybsen所说,当出现错误时会返回500状态代码。在使用cfheader命中页面之前可能会发生错误(因此可以在设置状态代码之前中止处理)或者在file_not_found.cfm中,其中错误状态代码将覆盖您设置的状态代码。
答案 1 :(得分:0)
这里主要关注的是500。您可以在IIS中启用“失败的请求跟踪”,因为Web服务器会抛出错误500.同时,分析异常/应用程序日志以获取相关信息。
答案 2 :(得分:-2)
我还想在这个问题上找到一个更有用的答案,这个问题在Windows 2008 R2上的CF10中仍然可以重现。
我创建了一个带有空白Application.cfc的新目录,其中包含一个包含以下内容的Index.cfm页面:传入200以外的任何状态代码,返回500错误代码。
<cfparam name="StatusCode" default="200">
<cfparam name="StatusText" default="OK">
<cfif StatusCode EQ "200">
<cfset variables.message = "Success">
<cfelse>
<cfset variables.message = StatusText>
</cfif>
<cfheader statuscode="#StatusCode#" statustext="#StatusText#">
<cfoutput>Message:#variables.message#</cfoutput>
<cfabort>