简体   繁体   English

WordPress 随机返回404错误

[英]WordPress randomly returns 404 errors

For the last few months, I notice a strange error on a Wordpress installation.在过去的几个月里,我注意到 Wordpress 安装出现了一个奇怪的错误。 It randomly shows 404 error pages for existing posts.它随机显示现有帖子的 404 错误页面。 There is no pattern in the frequency of the error, and affected pages include the front page, posts, pages and custom posts pages.错误的频率没有规律,受影响的页面包括首页、帖子、页面和自定义帖子页面。

The error log shows these entries:错误日志显示以下条目:

PHP Warning:  Use of undefined constant STYLESHEETPATH - assumed 'STYLESHEETPATH' (this will throw an Error in a future version of PHP) in /path/wp-includes/template.php on line 634
PHP Warning:  Use of undefined constant TEMPLATEPATH - assumed 'TEMPLATEPATH' (this will throw an Error in a future version of PHP) in /path/wp-includes/template.php on line 637

I included some further debugging code on the 404.php template and noticed that when the error occurs, both $wp->matched_rule and $wp->matched_query are empty.我在 404.php 模板上添加了一些进一步的调试代码,并注意到当错误发生时, $wp->matched_rule$wp->matched_query都是空的。 When the page is reloaded a few minutes later, the problem disappears and the correct content is shown again.几分钟后重新加载页面时,问题消失并再次显示正确的内容。

There are some large plugin installed that could play a role in this, including WPML, W3 Total Cache and WooCommerce.安装了一些大型插件可以在其中发挥作用,包括 WPML、W3 Total Cache 和 WooCommerce。 I have a staging system set up on the same webserver but the issue does only appear on the live system, so high traffic (40,000 hits/day) and a large database (wp_posts has 400,000 entries) could also be a factor.我在同一个网络服务器上设置了一个暂存系统,但问题只出现在实时系统上,因此高流量(每天 40,000 次点击)和大型数据库(wp_posts 有 400,000 个条目)也可能是一个因素。 Unfortunately, I cannot disable plugins on the live system for debugging.不幸的是,我无法禁用实时系统上的插件进行调试。

Any help as to what could be the cause of this problem would be greatly appreciated.任何有关可能导致此问题的原因的帮助将不胜感激。 Thanks!谢谢!

Might be caused by heavy traffic.可能是交通繁忙造成的。 When you have a heavy load, should consider to increase the server side performance.当你有很重的负载时,应该考虑增加服务器端的性能。

The LiteSpeed Server is worth a try. LiteSpeed 服务器值得一试。 But it has a learning curve if you are not familiar with it before.但是如果你以前不熟悉它,它有一个学习曲线。 Along with the plugin https://wordpress.org/plugins/litespeed-cache/连同插件https://wordpress.org/plugins/litespeed-cache/

This is not a quick solution.这不是一个快速的解决方案。 If your concern is that PHP Warning, just define it somewhere, or search it in your WP, find where its defined.如果您担心 PHP 警告,只需在某处定义它,或在您的 WP 中搜索它,找到它的定义位置。 If its defined in other places but not your 404 page, on 404 page it will throw that warning or error.如果它在其他地方定义但不是您的 404 页面,则在 404 页面上它会抛出该警告或错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM