Default page for 404 Not found

Hello,

I am working on simple CMS app. When the page which is requested isn’t found I want to show custom 404 with links and other information. In general I already have this functionality done but the custom 404 page is sent with 404 http response code. I can see it in firebug.

How can I generate custom 404 page with no HTTP error code. I want to send to the browser 200 OK not 404.

Thanks in advance

Why? :huh:

Why not ?

Because it doesn’t make any sense, that’s why.

You are not right.

404 means file is not available. However the content is dynamic and there is a ‘file’ . It shows different content but I think it is wrong to show whole regular page with 404 http response code.

Also if you do not know how to help others do not try.

Well, if it’s just modifying the error page: You’ll find that in application.views.site/error.php. But I still think it’s wrong to change the response code. 404 might be known as “File not found” but it actually means that the webserver couldn’t find any content for display at the given URL.

cf RFC 2616, section 10.4.5.

10.4.5 404 Not Found

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

In my case the server founds something that matching Request URI and this is custom page, so I do not need http 404 status code.

Yeah … but what is being “found” is your custom 404 page, isn’t it?

Actually it is not custom 404 page. There is no error content. This page may be created from CMS and it may contains everything.

I think there is a fundamental flaw in your concept. It looks like all you need to do is tweaking your URL routing: http://www.yiiframework.com/doc/guide/1.1/en/topics.url

You may be right. I am going to read this chapter again.

He’s definitely right :P Either way, always throwing a 200 code in place of a 404 is a recipe for disaster If things go really badly, you may even get penalised by search engines by having what appear to be an unlimited amount of valid pages with duplicate data.

I achieve what I need with URL Management primitives.

Thanks a lot colleagues!