How do I create a custom error page (404) for Joomla 1.6?

偶尔善良 提交于 2019-12-05 20:51:32

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:

  1. Create a Category (Uncategorized) (see if it’s not already there by default)
  2. Create an article
    • Title: 404
    • Category: Uncategorized
    • Article Content: Opps, Page not Found (or something else)
  3. Create a hidden menu
    • Menu -> Menu Manager
    • Title: Hidden, Menu Type: Hiddenmenu
  4. 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)
  5. 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;}
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!