How do I create a custom error page (404) for Joomla 1.6?
How do I create a custom error page (404) for Joomla 1.6?
I've tried a tutorial (http://docs.joomla.org/Tutorial:Create_a_Custom_404_Error_开发者_运维百科Page) but it's for 1.5 and it's not working.
Thank you.
The call to ->code is a call to a protected property, aka not possible any more. You have to use getCode(). The fixed code for 1.6 :
if ($this->error->getCode() == '404') {
header('Location: /index.php?option=com_content&view=article&id=214');
exit;
} ;
This works for Yoomla 1.6 now. ( as a fix for the 1.5 example on http://docs.joomla.org/Creating_a_Custom_404_Error_Page - the rest on this page is accurate)
I think i'd solve this with a more traditional approach and simply edit the .htaccess file.
I think this is also a more search engine friendly approach too.
For some creative
Just simply follow these steps:
- Create a Category (Uncategorized) (see if it’s not already there by default)
- Create an article
- Title: 404
- Category: Uncategorized
- Article Content: Opps, Page not Found (or something else)
- Create a hidden menu
- Menu -> Menu Manager
- Title: Hidden, Menu Type: Hiddenmenu
- Create a menu item inside this Hidden menu
- Menu Type: Single Article
- Title: Page not found
- Alias: page-not-found
- Template: your template which you want to use to show that page not found
- Link Article: to the article you have created in our case 404
- Robots: no index; no follow (for google to avoid indexing this page)
Then add this piece of code in your error.php of joomla you can find that inside (root_directory)\templates\system\error.php
defined( '_JEXEC' ) or die( 'Restricted access'); if ($this->error->getCode() == '404' ) { header('Location: http://www.domain.com/page-not-found'); exit;}
精彩评论