-
AuthorPosts
-
anisjolly Friend
anisjolly
- Join date:
- April 2008
- Posts:
- 661
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 33
- Thanked:
- 96 times in 55 posts
February 27, 2009 at 8:36 am #138624Do you hate it when you have broken links on your site or that dreaded error page with the 404 message appears and it looks nothing like your website???
Well, today you’re going to learn how you can change all that by simply editing one piece of code in your Joomla site.
For an example of what i’m talking about – just visit one of my sites (links in the signature) and at the end of the URL – just add some text to try and break my site – don’t worry all is in order – i’m pretty sure you won’t see the joomla error message. Once you’ve done that – return back here to continue with the modification tutorial.
To help you with this, I’m going to share with you my own error page and I’ll highlight the code below you need to change in order to customize your 404 page.
But before we start doing this, you need to create an article in the article manager. Call it whatever you want and put in whatever message you want your visitors to see when they come across the broken link / error page.
Make sure you publish it the the Uncategorized section and category.
Once you’ve done that – download my own error page (linked below) and then change the following code in the file you’ve just downloaded:
/* Custom Error Page Mod Code */
if (($this->error->code) == ‘404’) {
echo file_get_contents(‘PUT URL FOR YOUR NEWLY CREATED ERROR ARTICLE HERE‘);
}
else
{Your URL for your error article would look something like: http://www.anisjolly.co.uk/index.php?option=com_content&view=article&id=66 (if you’ve not setup SEF etc). If you have SEF enabled you’ll need to figure out the URL.
Ok, we’ve nearly finished. Once you’ve done the amendment in the file, upload this amended file to the following folder in your joomla site:
templates/system/
It’s as simple as that – you’re all done. to test out the error page – just do what you tried to do on my site and see if your custom error page works!
If you have any problems or would like me to do this for you – just leave a message below in this thread or send me a pm and i’ll be happy to help.
jsliao Friendjsliao
- Join date:
- April 2008
- Posts:
- 817
- Downloads:
- 0
- Uploads:
- 12
- Thanks:
- 25
- Thanked:
- 236 times in 210 posts
February 27, 2009 at 8:38 am #293729Well technically, sites should never encounter 404 errors if it was well built but mistakes happens and its definately nicer to have a page like this than the default 404 error page.
Great tip! Bookmarking this one!
questbg Friendquestbg
- Join date:
- May 2008
- Posts:
- 1912
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 146
- Thanked:
- 339 times in 197 posts
February 27, 2009 at 9:58 am #293774Cheers anisjolly, awesome! I’m on it now 😀
bennitos Friendbennitos
- Join date:
- May 2008
- Posts:
- 1717
- Downloads:
- 0
- Uploads:
- 39
- Thanks:
- 39
- Thanked:
- 474 times in 407 posts
February 27, 2009 at 11:21 am #293793Nice one anisjolly,
If there are users who have 404sef installed then you can do this with 404sef aswell.
It has a simple editor screen where you can make your custom 404 message, or you can decide that instead of showing a 404 error to direct users to a existing article like your frontpage.On your 404sef control panel go to the main tab and look for “404 Page”
Also look at the “404 page” tab where you can use the editor to create a custom msg.gray Friendgray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
February 12, 2010 at 8:33 pm #332533Very useful topic! I’m also thinking about creating an custom 404 page.
BTW, here is some addition information http://docs.joomla.org/Custom_error_pagesgray Friendgray
- Join date:
- October 2009
- Posts:
- 957
- Downloads:
- 0
- Uploads:
- 17
- Thanks:
- 28
- Thanked:
- 292 times in 230 posts
February 14, 2010 at 7:14 pm #332713So, I’ve created the custom error page. I followed recommendations by Google and included:
– home page link
– Joomla main menu links
– Joomla search field
– Google Analytics tracking codeAll this was implemented with error.php and error.css files. Those interested could contact me via PM.
power_on Friendpower_on
- Join date:
- July 2007
- Posts:
- 4
- Downloads:
- 0
- Uploads:
- 0
- Thanks:
- 4
- Thanked:
- 1 times in 2 posts
February 14, 2010 at 9:39 pm #332724Woow.
Thank you for sharing this.
March 27, 2010 at 11:21 pm #338066Don’t hack the Joomla core code, future updates will overwrite your changes…
Instead, simply put the error.php file in your chosen template directory. Joomla will find it and use it instead of the default file.
For example, the new location will be at:
yourwebsite.com/templates/yourtemplatename/error.phpThis is probably a better way of doing it…
http://docs.joomla.org/Custom_error_pagesI do have a question- how do you add the 404 error page (or whatever your article is called) without adding a menu item?
skydebaun.com
September 2, 2010 at 3:27 am #354404<em>@anisjolly 114969 wrote:</em><blockquote>Do you hate it when you have broken links on your site or that dreaded error page with the 404 message appears and it looks nothing like your website???
Well, today you’re going to learn how you can change all that by simply editing one piece of code in your Joomla site.
For an example of what i’m talking about – just visit one of my sites (links in the signature) and at the end of the URL – just add some text to try and break my site – don’t worry all is in order – i’m pretty sure you won’t see the joomla error message. Once you’ve done that – return back here to continue with the modification tutorial.
To help you with this, I’m going to share with you my own error page and I’ll highlight the code below you need to change in order to customize your 404 page.
But before we start doing this, you need to create an article in the article manager. Call it whatever you want and put in whatever message you want your visitors to see when they come across the broken link / error page.
Make sure you publish it the the Uncategorized section and category.
Once you’ve done that – download my own error page (linked below) and then change the following code in the file you’ve just downloaded:
/* Custom Error Page Mod Code */
if (($this->error->code) == ‘404’) {
echo file_get_contents(‘PUT URL FOR YOUR NEWLY CREATED ERROR ARTICLE HERE‘);
}
else
{Your URL for your error article would look something like: http://www.anisjolly.co.uk/index.php?option=com_content&view=article&id=66 (if you’ve not setup SEF etc). If you have SEF enabled you’ll need to figure out the URL.
Ok, we’ve nearly finished. Once you’ve done the amendment in the file, upload this amended file to the following folder in your joomla site:
templates/system/
It’s as simple as that – you’re all done. to test out the error page – just do what you tried to do on my site and see if your custom error page works!
If you have any problems or would like me to do this for you – just leave a message below in this thread or send me a pm and i’ll be happy to help.</blockquote>
this is an other solution, replace all content of system/error.php with this
<?php
// no direct access
defined( ‘_JEXEC’ ) or die( ‘Restricted access’ );/* Custom Error Page Mod Code */
$urlLink=JURI::base().”/index.php?option=com_content&view=article&id=157″;
$timeout=120;
$CR = curl_init();
curl_setopt($CR, CURLOPT_URL, “$urlLink”);
curl_setopt($CR, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($CR, CURLOPT_TIMEOUT, $timeout);
$response = curl_exec($CR);
curl_close( $CR );
$CR=explode(“</html>”,$CR);
echo $CR[1].”</html>”;
?>September 2, 2010 at 6:46 am #354411It is funny jokes i alway meet 404 for my website. By the way thank you for sharing this.
March 31, 2011 at 8:43 pm #384340Hi anisjolly,
You can try using this Qlue Custom 404 component. It will work straight after install.
It works like an article, you put in the html you want into your text editor and then your custom page will be displayed when there is an error. You can also add in modules into your custom pages and will also use your site’s template, saving you hours of editing the error.php file.
You can download it free here: http://www.qlue.co.uk/joomla-extensions-15-a-16/joomla-custom-404-error-page.html
-
AuthorPosts
This topic contains 11 replies, has 10 voices, and was last updated by nogrock 13 years, 8 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum