问题描述
我的wordpress网站上有近3000个帖子,最近被删除了.如何显示错误代码410而不是显示错误代码404,而不是显示所有已删除或未找到的帖子和页面?
您可以使用此插件会很方便,或者您可以按照给定的步骤来实现,而无需使用任何插件.
- 以错误410 (或使用您选择的任何名称)创建页面表单WordPress管理面板
- 在要显示给用户的页面上写内容.
- 发布页面后,您可以从URL获取页面ID
- 在活动主题
404.php
文件中添加给定代码.
404.php
$custom_410_page_ID = 25;//Error 410 page ID
header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");
header("Refresh: 0; url=" . get_permalink($custom_410_page_ID));
exit();
现在,当任何人访问您的旧URL或输入任何错误的URL时,它将被重定向到错误410 页面,并将410状态代码重定向到.
参考:将所有404移动到410
希望这会有所帮助!
My wordpress site has nearly 3000 posts that was deleted recently. Instead of showing error code 404, How do I show error code 410 to all deleted or not found posts and pages?
You can either use this plugin which will come handy for you, or you can follow the given steps to achieve this without using any plugin.
- Create a Page form WordPress Admin panel as Error 410 (or with any name of your choice)
- Write your content in that page which you want to show to the user.
- After publishing the page you can get the page ID from the URL
- Add the given code in your active theme
404.php
file.
Code for 404.php
$custom_410_page_ID = 25;//Error 410 page ID
header($_SERVER["SERVER_PROTOCOL"] . " 410 Gone");
header("Refresh: 0; url=" . get_permalink($custom_410_page_ID));
exit();
Now when any on visit your old URL or mistype any URL it will be redirected to Error 410 page with 410 status code to .
Reference: Move All 404 To 410
Hope this helps!
这篇关于Wordpress将所有404更改为410错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!