无法获得IIS 7 / Coldfusion交付404 [英] Can't get IIS 7/Coldfusion to deliver 404

查看:166
本文介绍了无法获得IIS 7 / Coldfusion交付404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以...我们有一个自定义CMS。我们有一个重写规则,任何页面请求(当文件不存在时)转到root / index.cfm文件。我们在我们的数据库中搜索相关页面。如果页面存在,我们提供正确的模板等。如果页面不存在我想服务器上404页。现在我认为我不能这样做在IIS中,因为我需要处理在CF中的请求,所以它必须通过。该文件将始终存在。当页面不存在时,我尝试使用< cfheader statusCode =404> 然后包括一些html,它放置您正在寻找的资源已被删除,其名称更改或暂时不可用。在我的html之前的页面顶部。为了让它显示页面,我不得不从IIS中删除404状态代码处理程序。

So... we have a custom CMS. We have a rewrite rule that any page request (when a file doesn't exist) goes to the root/index.cfm file. There we search our DB for the page in question. If the page exists, we serve up the correct template,etc. If the page doesn't exist I want to server up a 404 page. Now I "think" I cannot do this in IIS since I need to handle the request in CF, so it has to get through. The file will always exist. When the page doesn't exist I've tried using <cfheader statusCode="404" > and then include some html, it puts The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. at the top of the page before my html. In order to get it to display the page I had to remove the 404 status code handler from IIS.

此外,当我抓取作为谷歌,它得到一个301。当我在Firefox中查看响应头时我得到。

In addition when I fetch as Google, it get's a 301. However when I view response headers in Firefox I get.

Transfer-Encoding: chunked
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 16 Jan 2013 21:31:42 GMT
404 Not Found

我尝试了重定向和各种各样的东西的组合。我打开让IIS处理404,如果有一种方式,但我不知道如何获得Coldfusion正确提供404,所以谷歌得到它正确。网站管理员工具对我很生气,因为我在这之前提供软404,所以我试图解决这个问题。

I've tried a combination of redirecting and all sorts of things. I open to letting IIS handle the 404, if there is a way, but I cannot figure out how to get Coldfusion to correctly deliver a 404 so Google gets it right. Webmaster tools gets mad at me because I am delivering "Soft 404s" before this point, so I am trying to fix that.

我也尝试设置< httpErrors existingResponse =PassThrough/> 无论做什么,但没有工作。我一直在查找其他线程试图找出这一点,只是不能。

I've also tried setting <httpErrors existingResponse="PassThrough" /> whatever the hell that does, but didn't work either. I've been looking up other threads trying to figure this out and just can't.

编辑:进一步看看,查看标题信息在Firebug& Chrome我清楚地看到标题说404.为什么Fetch as Bing和Fetch as Google有不同的说法?

Looking further into this, viewing the header info in both Firebug & Chrome I clearly see the headers say 404. Why would Fetch as Bing and Fetch as Google say differently?

我测试了如果我添加.cfm到URL,但它没有.cfm,它认为它是301. Firebug看到两者都是404.这似乎是一个谷歌问题。

I tested the fact that if I add .cfm to the URLs, it Fetch as Google will deliver see 404. However without the .cfm, it thinks it's 301. Firebug sees both as 404. This seems like a Google issue.

答案类型:

所以我今天早上做了更多的测试(在我添加了一笔奖金之后),我注意到了网站管理员工具正确地注意到我的一个页面为404.所以我开始研究它。我有一个添加尾部斜线规则。 Google通知 domain.com/page 为301(正确我猜)到 domain.com/page / 。但它确实注意到 domain.com/page / 作为一个404.我认为使用尾部斜杠规则,因为我有它是正确的方式,但是,我应该做一些事

So I was doing more testing this morning (Right after I added a bounty actually), and I noticed in webmaster tools, Google correctly noted one of my pages as a 404. So I started looking into it. I have an "Add Trailing Slash Rule". Google notices domain.com/page as a 301 (Correct I guess) to domain.com/page/. But it does notice domain.com/page/ as a 404. I think using the trailing slash rule as I have it is the right way, however, should I be doing something different, or is using the redirect with the slash the "correct" way of doing things, even though Google wants to ding me for it sometimes.

推荐答案

我不完全确定我遵循你的方法的细节,所以我会给你一些你需要看看,以使这种方法工作良好(或至少是最有效的

I'm not entirely sure I follow the specifics of your approach, so I will give you a few things that you need to look at in order to get this approach working well (or at least what has worked best for me).

在错误页面下,确保您的404错误页面设置为在此网站上执行网址(我通常将我设置为/404.cfm)。这将确保您的ColdFusion页面正确调用404页面(它听起来像你的工作正常)。

Under "Error Pages", make sure that your 404 error page is set to "Execute a URL on this site" ( I generally set mine to something like "/404.cfm"). This will make sure that your ColdFusion page is called correctly for 404 pages (it sounds like you have this working correctly).

在处理程序映射下,双击.cfm的处理程序。然后单击请求限制...按钮。它应该打开到映射选项卡。

Under "Handler Mappings", double-click on the handler for ".cfm". Then click the "Request Restrictions..." button. It should open to the "mappings" tab. The "Invoke handler only if request is mapped to:" checkbox should NOT be checked.

这真的可以跳过这种操作,因为这意味着IIS不会如果文件不存在,则调用ColdFusion。这不应该是一个问题,如果你的404设置正确,但仍然需要研究。

This can really trip up this sort of operation because it means that IIS won't invoke ColdFusion if the file doesn't exist. This shouldn't be an issue if your 404 is set up correctly, but still something to look into.

当你在处理程序映射部分, IsapiModule的路径为*。 Mine总是设置为ColdFusion - 不确定是否有区别。

While you are in the "Handler Mapping" section, look for the IsapiModule with a path of "*". Mine is always set to ColdFusion - not sure if that makes a difference or not.

另一件要看的是默认文档设置。请记住,在转发到文件夹时,这可能会对您造成影响。

The other thing to look at is the "Default Document" setting. Keep in mind that this could impact you when forwarding to a folder.

您还可以再次查看您的重写规则,并确保它不会添加斜杠,

You might also look at your rewrite rule again and make sure it isn't adding slashes where one already exists.

这篇关于无法获得IIS 7 / Coldfusion交付404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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