简体   繁体   中英

WordPress randomly returns 404 errors

For the last few months, I notice a strange error on a Wordpress installation. It randomly shows 404 error pages for existing posts. 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. 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. 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. 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. But it has a learning curve if you are not familiar with it before. Along with the plugin 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. If its defined in other places but not your 404 page, on 404 page it will throw that warning or error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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