HMVC custom 404 pages |
[eluser]Mikle[/eluser]
Hello! I'm using ME HMVC. How can I make custom 404 pages on it, if module or method of controller doesn't exist?
[eluser]karloff[/eluser]
ter are a couple of diffent way however i like Jerome's solution http://maestric.com/doc/php/codeigniter_404
[eluser]wiredesignz[/eluser]
Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
[eluser]Mikle[/eluser]
I extended CI_Exeption class and added redirect to 404 controller in show_404() function. And for Google I added header("HTTP/1.1 404 Not Found"); and it's work perfect, and I can use now show_404() in any controller!
[eluser]wiredesignz[/eluser]
You cannot 'redirect' to a different URL and then return the 404 header. You should return the 404 header from the invalid URL.
[eluser]Mikle[/eluser]
[quote author="wiredesignz" date="1247762174"]You cannot 'redirect' to a different URL and then return the 404 header. You should return the 404 header from the invalid URL.[/quote] Why? My MY_Exceptions.php: Code: class MY_Exceptions extends CI_Exceptions And in error_404.php: Code: class Error_404 extends Controller { It works ok!
[eluser]CISCK[/eluser]
I think wiredesignz means that for SEO reasons, it is recommended that you use use the initial invalid URL and its 404 header. You may be "confusing" search engines by changing the URL / redirecting to another page and then declaring a 404 error. That said, I'm not an SEO expert, so you may want to look into this further.
[eluser]Dan Horrigan[/eluser]
Why go through all of this to show a 404 page when CI already does one? Simply modify the error_404.php file in the errors folder in the application folder. This is by far the easiest way to do it.
[eluser]Mikle[/eluser]
My application has widgets and I use HMVC. I use main template with widgets and sitemap in content zone for 404 pages. |
Welcome Guest, Not a member yet? Register Sign In |