Welcome Guest, Not a member yet? Register   Sign In
Custom 404 error page
#1

[eluser]Dimitar Velkov[/eluser]
Can anyone can tell me how to make 404 error page like on code igniter site example on the link: http://codeigniter.com/jbk

Thanks in advance.
#2

[eluser]Barouma[/eluser]
The first thing you need to do is to add the following line to a file named ".htaccess" (without the enclosing quotes and with the preceding period). In most instances, no such file will exist, and you can simply create one with a text editor (such as Notepad on Windows).
ErrorDocument 404 /notfound.html

You will of course need to put a notfound.html file in the main web directory for the above directive to work.

The "ErrorDocument 404" directive essentially tells the Apache web server that whenever it cannot find the file it needs in that directory and its subdirectories, it is to use the document specified in the URL that follows.

One .htaccess file in your main directory will do the trick for that directory and its subdirectories. However, if you want a certain subdirectory to show a different 404 File Not Found message, you can always place a .htaccess file into that directory. This will override any .htaccess files you have in the parent directories.

Step Two: Creating Your Error Document File

What should go into your custom 404 File Not Found page?

It is insufficient to simply let the visitor know that the file could not be found. In order not to lose that visitor, you will have to provide him some way to locate the document he wanted, or you would have lost him.

Your page should have one or more of the following things:

1. A link to your main page, with a suggestion that the visitor can find what he wants there.
2. If you have a search engine for your website, you should definitely put a search box on that page. Many people prefer to simply type a query than to scan through your site map.
3. A link to your site map, which lists all the pages on your website.
4. If you know of frequently mistyped URLs on your site, you can even put links to the correct location directly on the page, so that visitors who arrive there from outside can quickly get to the correct page. Remember, you don't want to lose that visitor, so do all you can to help him.
5. Any other navigational aids that you may have - for example, if you have a drop down navigation menu on your normal pages, you should probably put one here as well.

If you like, you can even put a simple form on the page to allow your visitors to inform you of the broken link. However, the primary aim of this page is not to help you track bad links, but to make sure your visitor does not leave your site if what he wants can be found there.

Incidentally, you should make your 404 page larger than 512 bytes, even when you are testing. Otherwise Internet Explorer (IE) will load what it calls its built-in "friendly HTTP error message" instead of your 404 page.

Step Three: Testing the Error Document

When you're satisfied with your page, upload it together with your .htaccess file to your website. Then test it by typing a URL that you know does not exist.

Your error page should load up. From this error page, test to see that the links here lead to the pages you intended it to lead.
#3

[eluser]Dimitar Velkov[/eluser]
No, no. I don't need static html error page. I need dynamic php error. I want to load some view from some controller function. Is it possible to do some think like that with CI.

Thanks
#4

[eluser]sophistry[/eluser]
check this thread: http://ellislab.com/forums/viewthread/99088/
and this thread: http://ellislab.com/forums/viewthread/54807/




Theme © iAndrew 2016 - Forum software by © MyBB