A Free Template From Joomlashack

A Free Template From Joomlashack

Who's Online

We have 5 guests online

User login



How to display custom 404 error page in Joomla website PDF Print E-mail
Written by Administrator   
Monday, 02 June 2008 19:01

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 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 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 2008-07-30 13:50:13
I was trying to find this everywhere. It worked on the first attempt. Good job!
jpatti 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 2008-09-04 14:28:10
jpatti wrote:
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 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 2008-09-04 14:30:56
header("HTTP/1.0 404 Not Found"
Eibo 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 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 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)"
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
:angry::0:confused::cheer:B):evil::silly::dry:
:lol::kiss::D:pinch::(:shock::X:side:
:):P:unsure::woohoo::huh::whistle:;):s
Please input the anti-spam code that you can read in the image.

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

 
Joomla 1.5 Templates by Joomlashack