Discuz教程网

Discuz!X2.5用户UID链接伪静态修改,并解决由于用户名静态出现的问题,附伪静态规则

[复制链接]
authicon dly 发表于 2013-10-22 00:51:33 | 显示全部楼层 |阅读模式
使用平台:Dx2.5、IIS7.5

知识点:
1、首页、文章列表页的用户链接伪静态化。
例如:(http://www.discuz.net/home.php?mod=space&uid=859)转换为(http://www.discuz.net/uid-859.html)

2、可解决:伪静态开启,用户名是中文的,查看用户空间提示【抱歉,您指定的用户空间不存在】(http://www.discuz.net/thread-2621478-1-1.html)

3、官方后台提供的伪静态规则已经过时,这里仅提供适用于该主题的伪静态规则。IIS7.5(web.config)使用。




1、 ../source/function/function_forum.php    //函数库
修改:末尾添加
  1. //自定义函数
  2. function GetLastPosterId($UserName)//最后回复UID
  3. {
  4.         $sql = DB::query("SELECT uid FROM " . DB::table('common_member') . " WHERE username = '$UserName'");
  5.         $row = DB::fetch($sql);
  6.         return $row['uid'];
  7. }
复制代码
保留末尾:?>

2、 ../source/function/function_forumlist.php   //论坛首页
修改前:
  1. $lastpost['author'] = '<a href="home.php?mod=space&username='.rawurlencode($lastpost['author']).'">'.$lastpost['author'].'</a>';
复制代码
修改后:
  1. $lastpost['author'] = '<a href="home.php?mod=space&uid='.GetLastPosterId($lastpost['author']).'" target="_blank">'.$lastpost['author'].'</a>';
复制代码
3、 ../template/default/forum/forumdisplay_list.htm  //列表页
修改前:
  1. <a href="{if $thread[digest] != -2}home.php?mod=space&username=$thread[lastposterenc]{else}forum.php?mod=viewthread&tid=$thread[tid]&page={echo max(1, $thread[pages]);}{/if}" c="1">$thread[lastposter]</a>
复制代码
修改后:
  1. <a href="{if $thread[digest] != -2}home.php?mod=space&uid={echo GetLastPosterId($thread[lastposter]);}{else}forum.php?mod=viewthread&tid=$thread[tid]&page={echo max(1, $thread[pages]);}{/if}" c="1">$thread[lastposter]</a>
复制代码
PS:需要对应的伪静态规则,否则会报错。

以上内容Dx2.0和Dx2.5是一致的,下边提供伪静态规则:
注意:该规则为Web.config文件,其他环境请自行对照修改。
游客,如果您要查看本帖隐藏内容请回复



上一篇:教你在Discuz!X3.1关闭帖子列表的快速发帖,并保留帖子的快速回复功能
下一篇:想搬家,不会,不知道怎好?
authicon rayty 发表于 2016-6-7 00:06:11 | 显示全部楼层
[s_catsoul=5]给力![/s_catsoul]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

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

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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