admin 发表于 2020-7-7 10:30:59

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

使用平台: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)使用。

http://www.discuz.net/static/image/hrline/4.gif


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

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

以上内容Dx2.0和Dx2.5是一致的,下边提供伪静态规则:
注意:该规则为Web.config文件,其他环境请自行对照修改。

浅生 发表于 2020-7-7 10:31:09

给力!
页: [1]
查看完整版本: Discuz!X2.5用户UID链接伪静态修改,并解决由于用户名静态出现的问题,附伪静态规则

创宇盾启航版免费网站防御网站加速服务