2

I am currently in the process of creating a custom 500 page for a wordpress website. I manually break the site using this in the header:

  <?php header('location : '); ?>

in the .htaccess I have this:

ErrorDocument 500 /wp-content/500.php

I had it as /wp-content/500.html in the htaccess and that worked beautifully. But I actually want it as .php, but for some reason it gives me this error: "This site can't be reached. The connection was reset" on chrome and a similar error on a different browser.

Why doesn't a .php site not work for a 500 error page? Is it because of the way I broke it?

Thank you in advance.

PepperAddict
  • 474
  • 2
  • 6
  • 13

2 Answers2

2

If your page /wp-content/500.php also generate an error (so it goes to the ErrorDocument 500, then again, …), it may do an infinite loop.

You can check the apache/php errors logs which may gives you additionnal clue.

You can also activate the Wordpress Debug mode by adding the following code in your wp-config.php:

define('WP_DEBUG', true);

You can try to add at the top of your 500.php page (after <?php ) something like die("This works so far at line ".__LINE__);.

Asenar
  • 5,861
  • 2
  • 31
  • 46
  • Thank you @Asenar! This has definitely helped me understand the problem more! Unfortunately it didn't fix it but I feel like I'm getting closer thanks to your reply. – PepperAddict Apr 26 '18 at 15:28
  • 1
    Did you see the paragraph I added ? If you see the message, you can edit `500.php` and add a lot of `echo 'this works so far at line '.__LINE__.PHP_EOL;`. An other solution is to comment the ErrorDocument line in `.htaccess` and call directly `500.php` (+ allowing error display). – Asenar Apr 26 '18 at 15:33
0

The http 500 error is a server error.

This mean your script failed and did not complete.

You must investigate why the error happened by checking your server and php logs.

Don't try to hide or handle it, it can cause full crash, database errors, and probably mean a security concern.

Derek Pollard
  • 6,238
  • 6
  • 34
  • 51
NVRM
  • 6,477
  • 1
  • 51
  • 60