如何使用自定义页面覆盖默认的 WordPress 404 页面?
我之所以无法使用正常的404.php WordPress模板文件是因为我的主机。我猜是一个 IP(可能是爬虫)不断查看 404 页面并发送 SQL 查询。由于我位于共享主机上,他们告诉我安装 WP Super Cache(我这样做了)并在我的 htaccess
文件中添加 ErrorDocument 404
指令,但事实并非如此。不工作。
应该在哪里添加它以覆盖 WP 默认值?
与此同时,我已将 404.php 更改为简单的 html 文件。那不会发送任何 SQL 请求,对吗?
多谢, 克里斯
The reason why I can't use the normal 404.php Wordpress template file is because of my host. An IP (crawler maybe) kept viewing 404 pages and sending SQL queries I guess. Since I'm on a shared host, they told me to install WP Super Cache (which I did) and add an ErrorDocument 404
directive in my htaccess
file but that doesn't work.
Where it should be added so it overrides WP default one?
In the meantime, I've changed the 404.php to a simple html file. That won't send any SQL requests right?
Thanks a lot,
Cris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
404 页面(包括 WP 的默认页面)不应触发 SQL 查询。当 SQL 已经确定它无法找到所请求的内容时,您最终会看到这个页面。
SQL 活动较高的常见原因之一是您定义永久链接结构的方式。使用“postname”很诱人(但也是致命的)。这是我能想到的让自己陷入此类问题的最常见方法。
但我确信还有更多我还没有发现......
The 404 page (including the default one from WP) shouldn't be firing SQL queries. It's the page you end up on when the SQL has already determined it can't find what's being asked for.
One common reason for high SQL activity is how you've defined your permalink structure. It's tempting (but deadly) to use "postname". It's the most common way I can think of to get yourself into this kind of a problem.
But I'm sure there are more I haven't discovered yet...