2

I want to use a custom 404 page for my website, so I followed the directions I found here and here.

However, when I trigger an error, the 404 message is embedded in the middle of my homepage, i.e., I see all modules assigned to it, and the message is right in the middle, where articles (and Joomla messages) would normally go.

enter image description here

The code I added to the top of the error.php file is as follows:

defined('_JEXEC') or die;

if (($this->error->getCode()) == '404') {   
  header("HTTP/1.0 404 Not Found");
  echo file_get_contents(JURI::root().'index.php?/es-co/option=com_content&view=article&id=23');
exit(0);
}

I only use those modules on the frontpage, and the menu I got the link from, is enabled but not assigned to any module.

What am I doing wrong?

You can take a look here.

1 Answer 1

2

Change

JURI::root().'index.php?/es-co/option=com_content&view=article&id=23'

to

JURI::root().'?option=com_content&view=article&id=23'

Reason:

JURI::root().'index.php?/es-co/option=com_content&view=article&id=23'

is being routed to (try it in your browser):

http://example.com/es-co/?/es-co/option=com_content&view=article&id=23

Which is loading that article, but routed through the homepage's menu item, so it'll load the article using the homepage's layout.

Making the suggested change will load the 404 article in the menu you had created for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.