Solution:
I asked Grok "Below is the Joomla version 6.0.3 error.php file from Helix Ultimate template to handle errors. Please modify it so that if a 404 error is generated, the system automatically redirects to the menu item: index.php?option=com_content&view=article&id=103"
Then pasted the .php code into the prompt
It gave me the code. I edited error.php and placed the code into the file. It worked.
Grok responded:
Insert the redirect logic right after the initial defined('_JEXEC') or die(); line and before any output (e.g., before the <html> tag or heavy processing). This ensures the redirect happens early.
I used Option 1...
Here is the code:
// === ADD THIS BLOCK FOR 404 REDIRECT ===
if (isset($this->error) && $this->error->getCode() == 404) {
// Option 1: Simple redirect using the raw query string (works reliably)
header('Location: ' . JUri::root() . 'index.php?option=com_content&view=article&id=103', true, 302);
exit;
// Option 2: Use JRoute for cleaner/SEF-friendly URL (recommended if SEF is enabled)
// JLoader::import('joomla.application.component.helper');
// $url = JRoute::_('index.php?option=com_content&view=article&id=103', false);
// header('Location: ' . JUri::root() . ltrim($url, '/'), true, 302);
// exit;
}
// === END OF REDIRECT BLOCK ===