查看 1354
回复 0
Discuz 增加404判断
逆风天

16

主题

0

回帖

105

积分
发表于 2021-12-4 20:01:48
显示全部楼层 阅读模式

需要修改 /source/function/function_message.php
打开 /source/function/function_message.php 查找
  1. if($param['location'] && !empty($_G['inajax'])) {
  2.   include template('common/header_ajax');
  3.   echo '<script type="text/javascript" reload="1">window.location.href=\''.$url_forward_js.'\';</script>';
  4.   include template('common/footer_ajax');
  5.   dexit();
  6. }
复制代码
在这个下面增加
  1. // 404 配置一 Editor By NFTStudio
  2. if(strpos($message, 'nonexistence') !== false || strpos($message, 'noexist') !== false || strpos($message, 'not_exist') !== false || strpos($message, 'nofound') !== false || strpos($message, 'no_found') !== false || strpos($message, 'not_found') !== false) {
  3.   header('HTTP/1.1 404 Bot Found');
  4. }

  5. // 404 配置二 Editor By NFTStudio
  6. if(strpos('/no(t_?|n|_|)(found|exist)/i', $message)) {
  7.   header('HTTP/1.1 404 Not Found');
  8. }
复制代码
以上代码 任意一种,即可!

您需要登录后才可以回帖 登录 立即注册
QQ 快速回复 返回列表