Discuz教程网

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

[复制链接]
authicon dly 发表于 2018-2-25 13:29:46 | 显示全部楼层 |阅读模式
部分插件跳转时,没带上网站域名,然后浏览器就默认以当前url路径为前缀进行跳转,导致链接错误
打开:source\function\function_core.php
找到
  1. function dheader($string, $replace = true, $http_response_code = 0) {
  2.         $islocation = substr(strtolower(trim($string)), 0, 8) == 'location';
  3.         if(defined('IN_MOBILE') && strpos($string, 'mobile') === false && $islocation) {
  4.                 if (strpos($string, '?') === false) {
  5.                         $string = $string.'?mobile='.IN_MOBILE;
  6.                 } else {
  7.                         if(strpos($string, '#') === false) {
  8.                                 $string = $string.'&mobile='.IN_MOBILE;
  9.                         } else {
  10.                                 $str_arr = explode('#', $string);
  11.                                 $str_arr[0] = $str_arr[0].'&mobile='.IN_MOBILE;
  12.                                 $string = implode('#', $str_arr);
  13.                         }
  14.                 }
  15.         }
  16.         $string = str_replace(array("\r", "\n"), array('', ''), $string);
  17.         if(empty($http_response_code) || PHP_VERSION < '4.3' ) {
  18.                 @header($string, $replace);
  19.         } else {
  20.                 @header($string, $replace, $http_response_code);
  21.         }
  22.         if($islocation) {
  23.                 exit();
  24.         }
  25. }
复制代码
修改为
  1. function dheader($string, $replace = true, $http_response_code = 0) {
  2.         global $_G;
  3.         $islocation = substr(strtolower(trim($string)), 0, 8) == 'location';
  4.         if($islocation){
  5.                 if(!preg_match('/location:\s*https?:\/\//is', $string)){
  6.                         $string = preg_replace("/location:\s*/is", 'Location: '.$_G['siteurl'], $string);
  7.                 }
  8.         }
  9.         if(defined('IN_MOBILE') && strpos($string, 'mobile') === false && $islocation) {
  10.                 if (strpos($string, '?') === false) {
  11.                         $string = $string.'?mobile='.IN_MOBILE;
  12.                 } else {
  13.                         if(strpos($string, '#') === false) {
  14.                                 $string = $string.'&mobile='.IN_MOBILE;
  15.                         } else {
  16.                                 $str_arr = explode('#', $string);
  17.                                 $str_arr[0] = $str_arr[0].'&mobile='.IN_MOBILE;
  18.                                 $string = implode('#', $str_arr);
  19.                         }
  20.                 }
  21.         }
  22.         $string = str_replace(array("\r", "\n"), array('', ''), $string);
  23.         if(empty($http_response_code) || PHP_VERSION < '4.3' ) {
  24.                 @header($string, $replace);
  25.         } else {
  26.                 @header($string, $replace, $http_response_code);
  27.         }
  28.         if($islocation) {
  29.                 exit();
  30.         }
  31. }
复制代码






上一篇:2018年Discuz!实物周边 豪华吹牛皮笔记本
下一篇:解除discuz禁止标签收录的限制
authicon  楼主| dly 发表于 2018-6-5 13:28:05 | 显示全部楼层

如果你的插件没问题,只是帖子偶尔打开连接错误,可以考虑下边的方法

打开 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自身对“主题有楼层不准确时”的一个操作,跳转是为了处理后刷新页面,但跳转时没带上域名,导致跳转错误
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-4-30 18:11

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表