·设为首页收藏本站📧邮箱修改🎁免费下载专区🔐设置/修改密码👽群雄群聊
返回列表 发布新帖

SEO超级伪静态 目录化伪静态后,有时点击跳转到错误链接的解决办法

353 1
发表于 2020-7-8 10:19:19 | 显示全部楼层 阅读模式

马上注册,免费下载更多dz插件网资源。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
部分插件跳转时,没带上网站域名,然后浏览器就默认以当前url路径为前缀进行跳转,导致链接错误
打开:source\function\function_core.php
找到
  1. function dheader($string, $replace = true, $http_response_code = 0) {        $islocation = substr(strtolower(trim($string)), 0, 8) == 'location';        if(defined('IN_MOBILE') && strpos($string, 'mobile') === false && $islocation) {                if (strpos($string, '?') === false) {                        $string = $string.'?mobile='.IN_MOBILE;                } else {                        if(strpos($string, '#') === false) {                                $string = $string.'&mobile='.IN_MOBILE;                        } else {                                $str_arr = explode('#', $string);                                $str_arr[0] = $str_arr[0].'&mobile='.IN_MOBILE;                                $string = implode('#', $str_arr);                        }                }        }        $string = str_replace(array("\r", "\n"), array('', ''), $string);        if(empty($http_response_code) || PHP_VERSION < '4.3' ) {                @header($string, $replace);        } else {                @header($string, $replace, $http_response_code);        }        if($islocation) {                exit();        }}
复制代码
修改为
  1. function dheader($string, $replace = true, $http_response_code = 0) {        global $_G;        $islocation = substr(strtolower(trim($string)), 0, 8) == 'location';        if($islocation){                if(!preg_match('/location:\s*https?:\/\//is', $string)){                        $string = preg_replace("/location:\s*/is", 'Location: '.$_G['siteurl'], $string);                }        }        if(defined('IN_MOBILE') && strpos($string, 'mobile') === false && $islocation) {                if (strpos($string, '?') === false) {                        $string = $string.'?mobile='.IN_MOBILE;                } else {                        if(strpos($string, '#') === false) {                                $string = $string.'&mobile='.IN_MOBILE;                        } else {                                $str_arr = explode('#', $string);                                $str_arr[0] = $str_arr[0].'&mobile='.IN_MOBILE;                                $string = implode('#', $str_arr);                        }                }        }        $string = str_replace(array("\r", "\n"), array('', ''), $string);        if(empty($http_response_code) || PHP_VERSION < '4.3' ) {                @header($string, $replace);        } else {                @header($string, $replace, $http_response_code);        }        if($islocation) {                exit();        }}
复制代码
我要说一句 收起回复
一花一世界,一叶一追寻。一曲一场叹,一生为一人。

评论1

TyCodingLv.8 发表于 2020-7-8 10:19:37 | 显示全部楼层
如果你的插件没问题,只是帖子偶尔打开连接错误,可以考虑下边的方法

打开 source\module\forum\forum_viewthread.php
找到
  1. dheader("Location:forum.php?mod=viewthread&tid=$_G[tid]");
复制代码
改成
  1. dheader("Location:$_G[siteurl]forum.php?mod=viewthread&tid=$_G[tid]");
复制代码


这是discuz自身对“主题有楼层不准确时”的一个操作,跳转是为了处理后刷新页面,但跳转时没带上域名,导致跳转错误
我要说一句 收起回复

回复

 懒得打字嘛,点击右侧快捷回复【查看最新发布】   【应用商城享更多资源】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

投诉/建议联系

discuzaddons@vip.qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,按照公告处理!!!
  • 联系QQ客服
  • 添加微信客服

联系DZ插件网微信客服|最近更新|Archiver|手机版|小黑屋|DZ插件网! ( 鄂ICP备20010621号-1 )|网站地图

您的IP:3.145.105.105,61.170.99.82,GMT+8, 2024-4-29 12:26 , Processed in 0.264234 second(s), 78 queries , Gzip On, Redis On.

Based on Discuz! W1.0 Licensed

© 2001-2024 Discuz! Team.

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表