CodeIgniter Forums
Create Custom 404 error page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Create Custom 404 error page (/showthread.php?tid=71877)



Create Custom 404 error page - imabot - 10-04-2018

Hi, I'm new to CodeIgniter, and it's not clear for me on how to create a custom 404 page. I already read the following posts :

https://forum.codeigniter.com/thread-66769.html
https://forum.codeigniter.com/thread-66110.html
https://forum.codeigniter.com/thread-64942.html
https://forum.codeigniter.com/thread-64591.html
https://forum.codeigniter.com/thread-64591.html
https://forum.codeigniter.com/thread-61587.html

and the following links:

https://stackoverflow.com/questions/34478283/codeigniter-3-0-custom-404-not-found-error-page
https://www.codexworld.com/codeigniter-custom-404-error-page/
http://www.bourzeix.com/weblog/post/2012/01/28/Page-404-personnalisee-avec-CodeIgniter
https://www.lucidar.me/en/codeigniter-3-1-9/how-to-create-a-custom-404-error-page-with-code-ignitor/

The last one is probably the most interesting and I concluded there are two options :
  • Update the content of /application/views/errors/html/error_404.php
  • Create a new route : $route['404_override'] = /myController/myMethod
None is satisfying because the first option prevent you from using custom templates for header and footer, and the second one doesn't work when the error_404() function is called.

What is the best practice to create a custom 404 error page ?


RE: Create Custom 404 error page - ignitedcms - 10-04-2018

You can create your custom 404 page, I'm doing it and it works fine.


RE: Create Custom 404 error page - imabot - 10-04-2018

(10-04-2018, 09:28 AM)ignitedcms Wrote: You can create your custom 404 page, I'm doing it and it works fine.

Did you read my question until the end ?


RE: Create Custom 404 error page - php_rocs - 10-08-2018

@imabot,

You could also just create an standard page and make it a custom error page. There is no rule that states that you have to reconfigure the CI error page.


RE: Create Custom 404 error page - imabot - 10-08-2018

(10-08-2018, 07:59 AM)php_rocs Wrote: @imabot,

You could also just create an standard page and make it a custom error page.  There is no rule that states that you have to reconfigure the CI error page.

Yes, this is what I did, but it's not working when calling the error_404() function. 

I finally used the solution described on this page : https://www.lucidar.me/en/codeigniter-3-1-9/how-to-create-a-custom-404-error-page-with-code-ignitor/

Not perfect, but do the job.


RE: Create Custom 404 error page - yafenic34 - 04-12-2020

(10-08-2018, 09:47 AM)imabot Wrote:
(10-08-2018, 07:59 AM)php_rocs Wrote: @imabot,

You could also just create an standard page and make it a custom error page.  There is no rule that states that you have to reconfigure the CI error page.

Yes, this is what I did, but it's not working when calling the error_404() function. 

I finally used the solution described on this page : https://www.lucidar.me/en/codeigniter-3-1-9/how-to-create-a-custom-404-error-page-with-code-ignitor/

Not perfect, but do the job.

I was working on new application krogerfeedback on my localhost, and tried to create a custom 404 but it always returned error.

But now, when i search for the solution. I got this thread and the reference guide mentioned hear really helped me.

Thanks, to Imabot.