Custom Error 404 not working

Need help with the Administration of your Joomla! 4.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Custom Error 404 not working

Post by MAD King » Fri Jul 01, 2022 10:04 pm

Hello,

I am trying to use the custom error code from J3 on J4, but it is not working.

When I enter a non-existing-link page I get the regular browser error:

This www.xxxxx.com page can’t be found.
No webpage was found for the web address: https://www.xxxxx.com/nonexistent-link
HTTP ERROR 404

Code in the error.php is

Code: Select all

if ($this->error->getCode() == '404') {
header("HTTP/1.0 404 Not Found");
echo file_get_contents(JURI::root().'https://www.xxxxx.com/index.php?option=com_content&view=article&id=7Itemid=173');
exit;
}

I also tried

Code: Select all

if (($this->error->getCode()) == '404') {
header('Location: ' . Jroute::_("index.php?option=com_content&view=article&id=7Itemid=173", false));
exit;
}
Same thing.

User avatar
AMurray
Joomla! Exemplar
Joomla! Exemplar
Posts: 7828
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: Custom Error 404 not working

Post by AMurray » Sat Jul 02, 2022 6:27 am

Seems the process is quite different for J4.

https://ltheme.com/create-a-custom-404- ... -joomla-4/
Regards - A Murray


Post Reply

Return to “Administration Joomla! 4.x”