[Locked] 404 - Too many redirects - Forum | JoomShaper
Solved Helix Framework Locked

404 - Too many redirects

Asked by SPD 3 years ago Last activity 3 years ago

Hi,
Trying to create a custom 404 page and following this article:
https://www.joomshaper.com/blog/create-a-custom-joomla-404-page-with-sp-page-builder

I have tested the page via the menu and all works well but when I implement the change to the error.php...
https://drive.google.com/file/d/1ykhg6ror7BwAAPW4sTIVBaFsQd2k4FFJ/view?usp=sharing

... I get another error of too many redirects. Maybe a problem with where I am placing code. Tried various position, the last one being at the very top of the file. Link above is the code I currently have

Accepted answer

Marked as the solution
Toufiq Senior Staff

I just added this code and change the id 10 with 221 (which is came from menu id)

https://prnt.sc/_s47M7s-tEYd

// custom 404 redirect
$config = JFactory::getConfig();
$sef = $config->get('sef');
$sef_rewrite = $config->get('sef_rewrite');
$sef_suffix = $config->get('sef_suffix');
$redirect_url = JURI::base();
if(!$sef_rewrite) {
    $redirect_url .= 'index.php/';
}
$redirect_url .= '404'; // menu alias
if($sef_suffix) {
    $redirect_url .= '.html';
}
// if sef is turned off
if(!$sef) {
    $redirect_url = 'index.php?option=com_sppagebuilder&view=page&id=10';
}
if (($this->error->getCode()) == '404') {
    header('Location: ' . $redirect_url, true, 301);
    exit;
}

code should be placed just under - defined ('_JEXEC') or die();

Check the screenshot

https://www.joomshaper.com/images/2020/09/04/custom-404.jpg

14 more replies

SPD Asked this

Hi,
I understand you're busy but hoping this could be an easy win. Any thought on what might be cuase my issue. I had forgotten to say using SP PB 3.8.9 and latest version of Helix
Thank You

Toufiq Senior Staff

Hi there,

Thanks for contacting us. Sorry for the inconvenience. Will you please provide me the Joomla administrator access to check the issue? I will check & get back to you soon. 

-Thanks

SPD Asked this

Info in hidden, but this is on a test subdomain so I will need to know what you did so I know what to do when I apply it to the live site.
Thank you

Toufiq Senior Staff

Please give me super administrator access. Thanks

Toufiq Senior Staff

Please check now. Thanks

SPD Asked this

Cheers, works great but that is a test site so I need to know what you did so I can set it up correctly on my Live site

Toufiq Senior Staff

Changed menu name and alias then replace the code again.

SPD Asked this
3 years ago · edited

So just so I can make note of what is not in article. The following is required when replace error 404 page

  • the menu name must match the in article OR you must update the code (// menu alias)
  • menu can not be a submenu as I see you did move that too
  • code should be placed just under - defined ('_JEXEC') or die();
SPD Asked this

I am pretty sure I had already added code , especially since the existing one still has my comments in it. Unfortuntely I didn't take a backup of that file before you went in and changed so I couldn't tell for certain.

While I thank you for fixing the file and I can understand that it is often easier as tech support/developer to just go in and see what is happening and change it... as the customer and developer of site, it is actually not ideal. I have no idea what has been done as you don't make any notes or comments which in the end just requires me to wait even longer to get the actual information I need as I have to come back and ask.

I need to learn how to fish, where you're just giving me one... if you know that proverb. ;-)

Anyway, thanks again for help

This question is locked, so it takes no new replies. Have a similar problem? Ask a new question.