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


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 page can’t be found.
No webpage was found for the web address:

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().'');

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));
Same thing.

User avatar
Joomla! Exemplar
Joomla! Exemplar
Posts: 7837
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. ... -joomla-4/
Regards - A Murray

Post Reply

Return to “Administration Joomla! 4.x”