custom error message or redirect to custom page if any error occurs

admin2025-01-07  6

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" to "www.demo/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

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

Share Improve this question edited May 14, 2018 at 10:20 Raxit asked May 14, 2018 at 10:12 RaxitRaxit 111 silver badge5 bronze badges 2
  • 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 Commented May 14, 2018 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 Commented May 14, 2018 at 10:43
Add a comment  | 

1 Answer 1

Reset to default 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/

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736259090a563.html

最新回复(0)