Custom 404 Error Page with Permalinks plugin

5 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 4, 2018   (RSS)

By leo - June 25, 2018

Hi Greg,

Yes, it is because of the redirecting. I would recommend you modify the 404 page to add the libraries you need.

Thanks,

Leo - PHP Programmer (in training)
interactivetools.com

By gversion - June 28, 2018

Thanks, Leo.

Could the plugin code not be changed slightly as follows:

  $alternate404Url = "http://www.mydomain.com/404.php";
  if (@$alternate404Url) {
    dieWith404(file_get_contents($alternate404Url));
    exit;
  }

Would that still redirect and then correctly send the 404 headers?

Thanks,

Greg

By gregThomas - July 2, 2018

Hey Greg,

That would work, but I'd recommend including the file path to the file instead of using the URL:

  $alternate404Url = "/path/to/404.php";
  if (@$alternate404Url) {
    dieWith404(file_get_contents($alternate404Url));
    exit;
  }

This is because there is a small chance that the file_get_contents to the URL might cause a 404, which could potentially cause an infinite loop.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gversion - July 4, 2018

Hi Greg,

Very good to know.

Thanks so much for the help!

Regards,

Greg