第二种,直接跳转
继续追寻中本聪的脚步

wordpress404页面自动301跳转到首页 返回状态码并跳转-iP反查域名网站

使用方法,选择以下代码添加到 文章的404页面 (404.php)

第一种,直接跳转

  1. <?php
  2. header("HTTP/1.1 301 Moved Permanently");
  3. header("Location: ".get_bloginfo("url"));
  4. exit();
  5. ?>

第二种,直接跳转

  1. <?php
  2. //WordPress 301 跳转到网站首页
  3. wp_redirect(home_url(), 301);exit;
  4. ?>

第三种,直接载入首页 返回 404 状态

  1. <?php
  2. //直接载入首页 返回 404 状态
  3. global $wp_query;
  4. $wp_query->set_404();
  5. status_header(404);
  6. nocache_headers();
  7. include( get_query_template( 'index' ) );
  8. die();
  9. ?>

第四种,返回 404 状态,然后通过 html 刷新跳转到首页

  1. <?php
  2. //返回 404 状态,然后通过 html 刷新跳转到首页
  3. global $wp_query;
  4. $wp_query->set_404();
  5. status_header(404);
  6. nocache_headers();
  7. echo '<meta http-equiv="refresh" content="0;url='.home_url().'">';
  8. exit;
  9. ?>

https://www.zmki.cn/5722.html


iP反查域名网站

https://site.ip138.com/


屏蔽垃圾蜘蛛

在网站 配置文件修改。

if ($http_user_agent ~* (SemrushBot|python|Linespider|crawler|DingTalkBot|simplecrawler|ZoominfoBot|zoombot|Neevabot|coccocbot|Facebot|YandexBot|Adsbot|DotBot|Applebot|DataForSeoBot|MJ12bot|BLEXBot|trendictionbot0|trendictionbot|AhrefsBot|hubspot|opensiteexplorer|leiki|webmeup)) { 
	return 444;
}

if ($http_user_agent ~* (SemrushBot|DotBot|MJ12bot|AhrefsBot|MauiBot|MegaIndex.ru|BLEXBot|ZoominfoBot|ExtLinksBot|hubspot|leiki|webmeup)) {
return 403;
}
赞(0) 群聊
文章链接:https://tucaod.xyz/10990.html
资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

神吐槽 抢沙发

讨论群终身200元

永远不解散,不涨价。不荐股、不带单。
ai学习安装,美股分析交流,不构成任何投资建议。终身免费指导。
AI产业链资料整理+资料库

联系我们

觉得文章有用就可以进群

继续追寻中本聪的脚步

支付宝扫一扫打赏