0

I am suppressing PHP errors from the front-end through .htaccess in WordPress. I want to hide the errors thrown by WordPress if we are trying to access a file through folder structure:

eg: www.my_site/wp-content/themes/twentyeleven/sidebar-page.php

.htaccess snippet:

php_flag display_errors off

But, it is showing a 500 internal server error. I've tried

error_reporting(0);
ini_set('display_errors', 0);

in the header.php file, no change. Is there any way to redirect to the homepage if a 500 error occurs?

DracSkywalker
  • 363
  • 4
  • 13
  • Possible duplicate of [php hide ALL errors](http://stackoverflow.com/questions/9242903/php-hide-all-errors) – MrWhite Oct 20 '15 at 11:30

1 Answers1

0

Try:

ErrorDocument 500 /index.php

That should cause any 500 error to redirect to the home page. The header will still have a 500 status, so it would be interesting to see how WordPress handles that.

Practically
  • 506
  • 4
  • 10
  • Fresh eyes on this: ErrorDocument handling tells apache what file to open when an error appears, it will not redirect. But if you put /index.php it should start the WordPress process and when WordPress's permalink logic grabs the path, it will not find a match and respond with the theme's 404. – Practically Oct 21 '15 at 19:45