Discuz教程网

[代码修改] Discuz X2版块绑定了二级域名后主题地址也变为二级域名的正式解决方法

[复制链接]
authicon dly 发表于 2011-5-15 17:32:15 | 显示全部楼层 |阅读模式
现象:如果您的网站将版块设置了二级域名,则在X2下访问这个二级域名而访问到对应版块的主题列表时,主题的链接地址也为二级域名的地址了。

正确的地址应该为网站在后台 → 域名设置 → 应用域名中设置的“默认”域名。

修改办法:(正式版解决办法)
找到 source/function/cache/cache_setting.php 文件的第 389 行附近
  1. $repflag = $apps['portal'] || $apps['forum'] || $apps['group'] || $apps['home'];
复制代码
修改为
  1. $repflag = $apps['portal'] || $apps['forum'] || $apps['group'] || $apps['home'] || $apps['default'];
复制代码

注:按照“临时方法”修改过的,请您还原代码。

===========================================================================

修改方法:(此为临时方法,稍后会有更加专业的修改办法)
找到 source/function/function_core.php 文件的第 1140 行附近
  1. function output_replace($content) {
  2. global $_G;
  3. if(defined('IN_MODCP') || defined('IN_ADMINCP')) return $content;
  4. $temp = parse_url($_G['siteurl']);
  5. if(!empty($_G['setting']['output']['str']['search'])) {
  6. if(empty($_G['setting']['domain']['app']['default'])) {
  7. $_G['setting']['output']['str']['replace'] = str_replace('{CURHOST}', $temp['host'], $_G['setting']['output']['str']['replace']);
  8. }
  9. $content = str_replace($_G['setting']['output']['str']['search'], $_G['setting']['output']['str']['replace'], $content);
  10. }
  11. if(!empty($_G['setting']['output']['preg']['search'])) {
  12. if(empty($_G['setting']['domain']['app']['default'])) {
  13. $_G['setting']['output']['preg']['search'] = str_replace('\{CURHOST\}', preg_quote($temp['host']), $_G['setting']['output']['preg']['search']);
  14. $_G['setting']['output']['preg']['replace'] = str_replace('{CURHOST}', $temp['host'], $_G['setting']['output']['preg']['replace']);
  15. }
  16. $content = preg_replace($_G['setting']['output']['preg']['search'], $_G['setting']['output']['preg']['replace'], $content);
  17. }

  18. return $content;
  19. }
复制代码

修改为如下代码
  1. function output_replace($content) {
  2. global $_G;
  3. if(defined('IN_MODCP') || defined('IN_ADMINCP')) return $content;
  4. $temp = parse_url($_G['siteurl']);
  5. /*
  6. if(!empty($_G['setting']['output']['str']['search'])) {
  7. if(empty($_G['setting']['domain']['app']['default'])) {
  8. $_G['setting']['output']['str']['replace'] = str_replace('{CURHOST}', $temp['host'], $_G['setting']['output']['str']['replace']);
  9. }
  10. $content = str_replace($_G['setting']['output']['str']['search'], $_G['setting']['output']['str']['replace'], $content);
  11. }
  12. */
  13. if(!empty($_G['setting']['output']['str']['search'])) {
  14. if(empty($_G['setting']['domain']['app']['default'])) {
  15. $_G['setting']['output']['str']['replace'] = str_replace('{CURHOST}', $temp['host'], $_G['setting']['output']['str']['replace']);
  16. } else {
  17. $_G['setting']['output']['str']['replace'] = str_replace('{CURHOST}', $_G['setting']['domain']['app']['default'], $_G['setting']['output']['str']['replace']);
  18. $_G['setting']['output']['str']['search'][] = $temp['host'];
  19. $_G['setting']['output']['str']['replace'][] = $_G['setting']['domain']['app']['default'];
  20. }
  21. } elseif(!empty($_G['setting']['domain']['app']['default'])) {
  22. $_G['setting']['output']['str']['search'] = $temp['host'];
  23. $_G['setting']['output']['str']['replace'] = $_G['setting']['domain']['app']['default'];
  24. }
  25. if(!empty($_G['setting']['output']['str']['search'])) {
  26. $content = str_replace($_G['setting']['output']['str']['search'], $_G['setting']['output']['str']['replace'], $content);
  27. }
  28. if(!empty($_G['setting']['output']['preg']['search'])) {
  29. if(empty($_G['setting']['domain']['app']['default'])) {
  30. $_G['setting']['output']['preg']['search'] = str_replace('\{CURHOST\}', preg_quote($temp['host']), $_G['setting']['output']['preg']['search']);
  31. $_G['setting']['output']['preg']['replace'] = str_replace('{CURHOST}', $temp['host'], $_G['setting']['output']['preg']['replace']);
  32. }
  33. $content = preg_replace($_G['setting']['output']['preg']['search'], $_G['setting']['output']['preg']['replace'], $content);
  34. }

  35. return $content;
  36. }
复制代码






上一篇:Discuz X2开启图片列表模式后,老帖子显示图片封面的解决方法
下一篇:安装首页KK_show首页N格不显示图片
authicon soul2511 发表于 2011-5-15 19:30:01 | 显示全部楼层
支持一下,确实是不错的贴子。
authicon yuki佳 发表于 2011-5-15 20:30:22 | 显示全部楼层
看帖必回
authicon qqoxygen 发表于 2011-5-15 22:29:40 | 显示全部楼层
喜欢喜欢喜欢
authicon 82xiaochong911 发表于 2011-5-15 23:29:40 | 显示全部楼层
哈哈,支持了
authicon kikiya11 发表于 2011-5-16 03:30:02 | 显示全部楼层
支持楼主,顶一下
authicon shakesxia 发表于 2011-5-16 04:29:47 | 显示全部楼层
前来看看那
authicon 皆无 发表于 2011-5-16 05:29:36 | 显示全部楼层
很好 很强大。。谢谢分享
authicon nmzc 发表于 2011-5-16 06:29:42 | 显示全部楼层
顶的就是你
authicon 纤陌陌 发表于 2011-5-16 16:29:52 | 显示全部楼层
楼主真强大
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-5-18 12:50

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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