A Free Template from Joomlashack

A Free Template from Joomlashack

User login



How to display custom 404 error page in Joomla website PDF Print E-mail

Have you ever wondered how to get rid of the default Joomla 404 page and display a custom page that shows links or search results, so that your visitors can navigate to other pages with out feeling lost? Well, I have and I was googling a bit and found out the following:

 

 


You can replace the above page with a custom page that looks exactly the same as the rest of your website. Here is what you have to do:

  • Create a new article page that you want to display for your users when they bump into 404 error. Please have a look on this website to get some inspiration how your 404 page should look like.
    http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded/

  • Now, in your “template” directory create a file called “error.php” and add the following code

<?php
defined( '_JEXEC' ) or die( 'Restricted index access' );
if (($this->error->code) == '404') {
header('Location: ' . $this->baseurl . 'my/404/article/page/url');
exit;
}

  • “my/404/article/page/url” is the url of your 404 article page. Replace it with the new article page that you have just created.

  • Now is testing time: Navigate to any page in your website and from the url of the page delete something and try to reach that location, your new error page should popup up.
RSS
Simply the best
Brannz (81.107.34.xxx) 2008-07-22 20:49:28
Fantastic! The best Joomla! 404 tutorial on the web.
Simple, to the point, gets
the job done!
THANK YOU MAN
nirzar (59.95.4.xxx) 2008-07-29 07:55:16
Awesome tip. they are crying over joomla forum about this.. simple and effective
solution..
thnx..
Principal/Creative Director
Works like a charm (207.188.205.xxx) 2008-07-30 13:50:13
I was trying to find this everywhere. It worked on the first attempt. Good job!
jpatti (206.251.12.xxx) 2008-08-21 21:53:30
It looks like this doesn't return a 404 header though. This is why it's a
question on the forums, people want to *both* return a 404 header and *also*
return a customized page.

Unless I'm misunderstanding, this code looks to
capture the 404 error and NOT return it to the browser.
re:
Anonymous (65.116.86.xxx) 2008-09-04 14:28:10
Unless I'm misunderstanding, this code looks to capture the 404 error and
NOT return it to the browser.

What if you add the HTTP error:

Anonymous (65.116.86.xxx) 2008-09-04 14:29:48
like this site:

http://www.joomlamafia.com/guides-for-jooom
la/how-to/2-custom-error-pages-404.html
Anonymous (65.116.86.xxx) 2008-09-04 14:30:56
header("HTTP/1.0 404 Not Found"
Eibo (85.144.17.xxx) 2008-09-28 10:30:49
I could not agree less with the other comments. As easy as drinking my beer ->
just do it!
Keith Cross (24.151.134.xxx) 2008-10-07 15:54:37
I'm not able to get this to work. I get a "Forbidden access (Flooding)"
message when I do this. Am I doing it wrong?
Keith Cross (24.151.134.xxx) 2008-10-07 15:59:20
I put the file called "error.php"
in:

public_html/joomla/templates/yoo_page/

and I created a Section called
"Error Pages" and a Category called "Error Pages" and an Artcile
called "Having Trouble?" with an alias of "404error"

ergo, the
path should be (and its relative, meaning
"http://www.waysideyouth.org/joomla" is appended with the following
path):

/Error-Pages/404error.html

RIGHT?


If I've done this wrong, please
clue me in, cause now I get a message "Forbidden Access (Flooding)"
re: same prtob but now works
rosa (89.127.163.xxx) 2008-10-12 12:13:56
I put the file called
"error.php" in:

public_html/joomla/templates/yoo_page/

and
I created a Section called "Error Pages" and a Category called
"Error Pages" and an Artcile called "Having Trouble?" with
an alias of "404error"

ergo, the path should be (and its
relative, meaning "http://www.waysideyouth.org/joomla"
is appended with the
following path):

/Error-Pages/404error.html

RIGHT?


If I've done
this wrong, please clue me in, cause now I get a message "Forbidden
Access (Flooding)"

hey the same thing happend to us but then we
undid the error page - took code out of template and yet the nice new 404
remained working! weird but true
update
Evan (65.188.210.xxx) 2008-10-23 19:46:13
Now, in your “template” directory create a file called “error.php”
and add the following code

Not sure when this changed, but as of
1.5 you need to put that file in the "template/system"
directory to have it work, being in the template folder won't do it.
Or at least, that was the only way it would work for me.
win (58.9.46.xxx) 2008-12-30 11:03:04
thanks a lot, it's work!
Picasso Fish (209.167.107.xxx) 2009-01-14 08:35:23
Please not that this is for Joomla! 1.5.x
Tanks
Oli (85.216.85.xxx) 2009-05-15 17:00:10
Thanks very much...good Job! I fixed that Problem immediately :-)
Only registered users can write comments!

3.23 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
Joomla 1.5 Templates by Joomlashack