该插件尚未通过WordPress的最新3个主要版本进行测试。 当与较新版本的WordPress一起使用时,可能不再受到维护或支持,并且可能会存在兼容性问题。

Custom Error Pages

描述

WordPress offers inbuilt support for custom 404 pages on all themes. But what about custom pages for other common errors like 401 and 403? You end up seeing a bland error page of the Web Server.

With this plugin you can easily create custom 401 and 403 error pages with any theme without writing a single line of code!!! And the best part is that you set it and forget it. Yes, you don’t have to do any changes even if you change themes. The heading and text you want on 401 and 403 error pages are displayed on the currently active theme.

Further Reading

屏幕截图

  • Modify the title and content values of your custom error page from Settings > Custom Error Pages
  • A Custom 403 Error page on the TwentyThirteen theme
  • A Custom 403 Error page on the Customizr theme
  • A Custom 403 Error page on the Expound theme

安装

  1. Install and activate the custom error pages plugin.
  2. From the wp-admin go to Settings > Custom Error Pages, fill in the heading and content boxes, save the changes and preview it.
  3. Configure your web server to use a custom error page.

Apache users edit your .htaccess file and add the following lines.

ErrorDocument 403 /index.php?status=403
ErrorDocument 401 /index.php?status=401

Nginx users edit your nginx.conf file and add the following lines.

error_page  403 = /index.php?status=403
error_page  401 = /index.php?status=401

Try accessing a file or directory which is forbidden like

http://www.example.com/.htaccess

http://www.example.com/wp-includes/

Did you see a custom 403 page in all the glory of your theme?

常见问题

Should I do anything if I change themes?

No not at all. You just install the plugin set it and forget it. The plugin isn’t theme bound so it’ll work even after switching themes.

I noticed define( ‘DONOTCACHEPAGE’, TRUE ); in the plugin code what is it for?

This tells caching plugins like W3 Total Cache and WP Super Cache not to cache the 401 and 403 error pages. This does NOT affect the cacheability any other pages of your site.

Does this plugin automatically edit the .htaccess or nginx.conf file?

No it doesn’t. You have to manually edit it and add the necessary configuration specified in the plugin’s option page.

评价

2023 年 5 月 26 日
Works exactly as described, letting you customize other default error messages besides just the 404 like most other plugins on this category do.
2020 年 1 月 14 日
Straight forward setup. I especially like that it adapts to the current theme.
2019 年 5 月 5 日
Actualy I was little scared of editing .htaccess. But I added it to bottom on .htaccess and it worked well. Excellent pugin! Thank you:)
2017 年 11 月 29 日
This plugin is simple to setup and use, all I did after activation was that I changed error message text and that was it! It saved me time on creating my own error pages on a simple wp site! Great work!
2017 年 9 月 3 日 1 回复
Just an feature request, can you add option to hide title? Because I prefer to use page builder plugin for better design.
阅读所有12条评价

贡献者及开发者

“Custom Error Pages” 是开源软件。 以下人员对此插件做出了贡献。

贡献者

将“Custom Error Pages”翻译成您的语言。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志

更新日志

1.2

  • Removed deprecated screen_icon() function
  • Compatibility check with WordPress 6.2

1.1

  • Fixed a bug that displayed the thumbnail of Post ID 1
  • Reduced repetitive code with inheritance
  • Compatibility check with WordPress 3.8

1.0

  • Initial version