0

I want to create custom message when site got any error or broken or it is also be helpful if I can redirect site url to my custom page when site got error for example "www.demo.com" to "www.demo.com/custom-error-message-page" where I can display my message to visitors and also want those error to notify in my email.

I have tried wp_debug in wp-config to set to true but it shows all error on all pages of site instead that I only want any custom message to show.

Thanks

  • Try some google research before asking. I just hit in "custom error page wordpress" and it gave me tons of results. Also, you shouldn't do that anyway as the errors have a specific reason and it is important to know what the error is. The fact that you try to show a custom error messages shows me that you rather try to hide/alter the error instead of fixing it. – marvinpoo May 14 '18 at 10:24
  • 1
    Thanks for your consideration, I only want to show custom message even in case of fatal error and also for 401,403 any such errors so only that custom page will be shown to visitor apart from that after enabling wp_debug I will get those errors in my email so I can resolve them. – Raxit May 14 '18 at 10:43
0

Now, that's actually pretty easy. Just create a 404.php and a 403.php and maybe a custom-error.php

Then you can setup your .htaccess with something like this:

ErrorDocument 500 /custom-error.php ErrorDocument XXX /custom-error.php

Please remember: you do not need that for the 404 and 403 as these are actually supported by the Wordpress Codex. For further Informations feel free to read the codex. Inside of the .php file you can do whatever.

--

Codex: https://codex.wordpress.org/Creating_an_Error_404_Page

Additional: https://premium.wpmudev.org/blog/customize-error-pages-wordpress/

  • Thank you for this, how can I do this for php errors like parse error(Syntax Error),fatal error..etc, so for server(apache) side I can handle error pages like we have discussed here , I mean all the issues which can break the page not showing site to visitor in that case I want to display custom page with message. I hope it will clear my problem and I will get any way to get solution. – Raxit May 15 '18 at 4:54
  • I am not really sure if you can do that. You might gotta ask in the Stackoverflow instead of this sub-stack – marvinpoo May 15 '18 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.