How do I create a custom 404 erro page? (solved)
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Thu Oct 15, 2009 2:12 pm
How do I create a custom 404 erro page? (solved)
Last edited by proveyourself on Wed Feb 16, 2011 4:15 pm, edited 1 time in total.
- OOmNezar
- Joomla! Ace
- Posts: 1869
- Joined: Mon Sep 07, 2009 3:18 am
Re: How do I create a custom 404 erro page?
Creating 404 page have many way. Try this to more understanding 404 page in Joomla.
http://docs.joomla.org/Custom_error_pages
or modified like : http://forum.joomla.org/viewtopic.php?f=428&t=593390
http://docs.joomla.org/Custom_error_pages
or modified like : http://forum.joomla.org/viewtopic.php?f=428&t=593390
coffee & smoke just fine
OOm Nezar
-
- Joomla! Apprentice
- Posts: 14
- Joined: Thu Oct 15, 2009 2:12 pm
Re: How do I create a custom 404 erro page?
I've made everthing from the first link but if I type something like "http://localhost:8888/joomla/foo" (this page doesn't exist) the error page is not called. I am redirected to the main page.
- OOmNezar
- Joomla! Ace
- Posts: 1869
- Joined: Mon Sep 07, 2009 3:18 am
Re: How do I create a custom 404 erro page?
use header() in the first line http://php.net/manual/en/function.header.php and located/redirect to where ever you want
coffee & smoke just fine
OOm Nezar
-
- Joomla! Apprentice
- Posts: 14
- Joined: Thu Oct 15, 2009 2:12 pm
Re: How do I create a custom 404 erro page?
No, no. You don't get what I said. I've placed a break point in error.php but it never reachs there.
Update: This link fix the issue.
Thank you.
Update: This link fix the issue.
Thank you.
- epidote
- Joomla! Apprentice
- Posts: 43
- Joined: Fri Jul 20, 2007 1:37 am
- Contact:
Re: How do I create a custom 404 erro page? (solved)
can't you just make a new item and menu and change the error.php from
to
that seems to work?
Code: Select all
if (!isset($this->error)) {
$this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
$this->debug = false;
}
Code: Select all
if (!isset($this->error)) {
$this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
$this->debug = false;
} else {
header('Location: /sorry-this-page-has-been-removed');
exit;
}
-
- Joomla! Apprentice
- Posts: 5
- Joined: Sat Oct 04, 2008 4:41 pm
Re: How do I create a custom 404 erro page? (solved)
The above code did not work for me, since upgrade to 2.5 my custom error page does not work, the code is different.
Would be useful if joomla reflected the new code in http://docs.joomla.org/Custom_error_pages
Created an uncategorised article, created a unpublished menu item
and copy error.php to template directory, then edited error.php to reflect link to the article that I created and put the url same as above, this did not work. Neither did using the full url.
deleted cache still did not work.
Would be useful if joomla reflected the new code in http://docs.joomla.org/Custom_error_pages
Created an uncategorised article, created a unpublished menu item
and copy error.php to template directory, then edited error.php to reflect link to the article that I created and put the url same as above, this did not work. Neither did using the full url.
deleted cache still did not work.
-
- Joomla! Apprentice
- Posts: 5
- Joined: Sat Oct 04, 2008 4:41 pm
How do I create a custom 404 error page in Joomla 2.5
Found this in another post
just change ID in the code above below to your own, it looks like this index.php?option=com_content&view=article&id=35
http://forum.joomla.org/viewtopic.php?p ... 2#p2729536
this appears to work fine for me, unless there is another way that is even better.
thank you duyet for the solution.
Code: Select all
<?php
/**
* @package Joomla.Site
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
if (!isset($this->error)) {
$this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
$this->debug = false;
}
//get language and direction
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;
if (($this->error->getCode()) == '404') {
header('Location: /index.php?option=com_content&view=article&id=35');
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
http://forum.joomla.org/viewtopic.php?p ... 2#p2729536
this appears to work fine for me, unless there is another way that is even better.
thank you duyet for the solution.
- chiappa
- Joomla! Intern
- Posts: 82
- Joined: Wed Oct 26, 2011 6:53 pm
- Location: Mostly Northeast Asia
- Contact:
Re: How do I create a custom 404 erro page? (solved)
Thank you technoboyuk that worked like a charm! And shame on Joomla for not updating their docs (plus the usual thanks...) :P
- kuknoor
- Joomla! Enthusiast
- Posts: 101
- Joined: Wed Sep 01, 2010 6:18 am
- Location: hyderabad,india
- Contact:
Re: How do I create a custom 404 erro page? (solved)
Thanks technoboyuk for helping out and am requesting admin's and mod's of this forum to update the joomla docs with the above fix bcoz joomla docs is outdated
-
- Joomla! Apprentice
- Posts: 39
- Joined: Sun Aug 07, 2011 10:02 am
- Location: Milky Way
Re: How do I create a custom 404 erro page? (solved)
Just wanted to ask the same question but I used search. That paid off
-
- Joomla! Apprentice
- Posts: 5
- Joined: Fri Nov 11, 2011 4:52 pm
Re: How do I create a custom 404 erro page? (solved)
I used technoboyuk's answer and it worked. However, I am getting this error message on my custom 404 page:
Trying to get property of non-object in mysite/templates/mytemplate/index.php on line 13
Line 13 of the index.php file is: $params = $menu->getParams( $active->id );
Any ideas on how to fix this?
Trying to get property of non-object in mysite/templates/mytemplate/index.php on line 13
Line 13 of the index.php file is: $params = $menu->getParams( $active->id );
Any ideas on how to fix this?
-
- Joomla! Apprentice
- Posts: 7
- Joined: Tue Nov 09, 2010 1:55 am
Re: How do I create a custom 404 erro page? (solved)
Thank you! That worked like a charm - after spending hours trying to follow instructions on Joomla's website, then trying to edit the .htaccess. Finally this worked!
- check out my custom 404 page: http://ashevillealetrail.com/index.php/404-error/
- check out my custom 404 page: http://ashevillealetrail.com/index.php/404-error/
- sandvelder
- Joomla! Apprentice
- Posts: 46
- Joined: Thu Sep 08, 2011 10:03 am
- Location: Pretoria, South Africa
- Contact:
Re: How do I create a custom 404 erro page? (solved)
Hi, I have read the thread above, I have already done as described above prior to getting to this post, but still no happiness! :-(
I have several Joomla 3 websites running at a small variety of ISP's.
I want to get a custom 404-error message displayed on all my websites, but fail to get it right.
I have already created the Joomla article for the message, and created a link (/index.php?option=com_content&view=article&id=24) to display it.
That was the easy part.
The help I get from the Joomla tutorials is also simple to execute, but it does not work.
As I understand it, there is an error.php under /templates/system, which should be copied to /templates/[template name] and then edited.
The following line should be added under the line "defined('_JEXEC') or die;" :
if (($this->error->getCode()) == '404') {
header('Location: /index.php?option=com_content&view=article&id=24);
exit;
}
Having done the above, my websites return a variety of messages, all but the intended custom message.
What I can see from these messages are that they change according to the Apache Server the website is running on.
In other words, the server overrides the CMS.
Any ideas on getting a custom 404 message displayed?
URLs:
http://magicbrush.co.za
http://max-con.co.za
http://it.doxadeo.co.za
http://raymonddye.co.za
http://gustavgreyling.co.za
http://dynamiclifeskill.co.za
http://skolierxpress.co.za
http://vilnard.co.za
I have several Joomla 3 websites running at a small variety of ISP's.
I want to get a custom 404-error message displayed on all my websites, but fail to get it right.
I have already created the Joomla article for the message, and created a link (/index.php?option=com_content&view=article&id=24) to display it.
That was the easy part.
The help I get from the Joomla tutorials is also simple to execute, but it does not work.
As I understand it, there is an error.php under /templates/system, which should be copied to /templates/[template name] and then edited.
The following line should be added under the line "defined('_JEXEC') or die;" :
if (($this->error->getCode()) == '404') {
header('Location: /index.php?option=com_content&view=article&id=24);
exit;
}
Having done the above, my websites return a variety of messages, all but the intended custom message.
What I can see from these messages are that they change according to the Apache Server the website is running on.
In other words, the server overrides the CMS.
Any ideas on getting a custom 404 message displayed?
URLs:
http://magicbrush.co.za
http://max-con.co.za
http://it.doxadeo.co.za
http://raymonddye.co.za
http://gustavgreyling.co.za
http://dynamiclifeskill.co.za
http://skolierxpress.co.za
http://vilnard.co.za
Francois Barnard
https://sandvelder.com
Pretoria
https://sandvelder.com
Pretoria
- jessicasclound9
- Joomla! Apprentice
- Posts: 23
- Joined: Sun May 24, 2015 10:06 pm
Re: How do I create a custom 404 erro page? (solved)
dpeschio wrote:Thank you! That worked like a charm - after spending hours trying to follow instructions on Joomla's website, then trying to edit the .htaccess. Finally this worked!
- check out my custom 404 page: http://ashevillealetrail.com/index.php/404-error/
looks good
Last edited by jessicasclound9 on Mon Jun 01, 2015 7:02 am, edited 1 time in total.
- chiappa
- Joomla! Intern
- Posts: 82
- Joined: Wed Oct 26, 2011 6:53 pm
- Location: Mostly Northeast Asia
- Contact:
Re: How do I create a custom 404 erro page? (solved)
Are you not using "Search Engine Friendly URLs"?sandvelder wrote:Hi, I have read the thread above, I have already done as described above prior to getting to this post, but still no happiness! :-(
Code: Select all
<?php
defined('_JEXEC') or die;
if (($this->error->getCode()) == '404') {
header('Location: /404');
exit;
}
?>
- sandvelder
- Joomla! Apprentice
- Posts: 46
- Joined: Thu Sep 08, 2011 10:03 am
- Location: Pretoria, South Africa
- Contact:
Re: How do I create a custom 404 erro page? (solved)
Thank you, but as I have said before, I have tried the above already. My 404 page does not show.
Francois Barnard
https://sandvelder.com
Pretoria
https://sandvelder.com
Pretoria
- chiappa
- Joomla! Intern
- Posts: 82
- Joined: Wed Oct 26, 2011 6:53 pm
- Location: Mostly Northeast Asia
- Contact:
Re: How do I create a custom 404 erro page? (solved)
Are you missing an apostrophe there (see below)? And have you tried using a SEF instead?
Code: Select all
header('Location: /index.php?option=com_content&view=article&id=24');
- sandvelder
- Joomla! Apprentice
- Posts: 46
- Joined: Thu Sep 08, 2011 10:03 am
- Location: Pretoria, South Africa
- Contact:
Re: How do I create a custom 404 erro page? (solved)
Hi, sharp of you to catch that! But alas, no, I did not miss it in the error.php file.
Francois Barnard
https://sandvelder.com
Pretoria
https://sandvelder.com
Pretoria
- sandvelder
- Joomla! Apprentice
- Posts: 46
- Joined: Thu Sep 08, 2011 10:03 am
- Location: Pretoria, South Africa
- Contact:
Re: How do I create a custom 404 erro page? (solved)
OK, I found the solution. But what I cannot grasp is the load of BS I had to go through to get to final solution.
I edited the empty .htaccess file and added the following line:
ErrorDocument 404 /index.php?option=com_content&view=article&id=24
Why does nobody mention this in these forums? I found this detail in a forum for Apache Web Servers:
http://www.4webhelp.net/tutorials/misc/errors.php
I edited the empty .htaccess file and added the following line:
ErrorDocument 404 /index.php?option=com_content&view=article&id=24
Why does nobody mention this in these forums? I found this detail in a forum for Apache Web Servers:
http://www.4webhelp.net/tutorials/misc/errors.php
Francois Barnard
https://sandvelder.com
Pretoria
https://sandvelder.com
Pretoria