Discuz x2.0的伪静态不生效,百翔通过搜集相关资料,发现这是官方发布Discuz x2.0时留下的一个BUG,只要通过小小的修改就能实现伪静态了。
好了,费话少说了,现转入正题。
首先要将这个BUG解决先,打开../source/function/function_core.php这个文件。
查找代码:
$_G['setting']['output']['preg']['search'] = str_replace('\{CURHOST\}', preg_quote($_G['siteurl']), $_G['setting']['output']['preg']['search']);
换成:
$_G['setting']['output']['preg']['search'] = str_replace('\{CURHOST\}', preg_quote($_G['siteurl'], '/'), $_G['setting']['output']['preg']['search']);
生成的httpd.ini放在根目录下:
[ISAPI_Rewrite]
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini 0758z.com parse.errors files
# 百翔社区规侧如下:from accessing through HTTP
RewriteRule ^(.*)/topic-(.+)\.html(\?(.*))*$ $1/portal\.php\?mod=topic&topic=$2&$4
RewriteRule ^(.*)/article-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/portal\.php\?mod=view&aid=$2&page=$3&$5
RewriteRule ^(.*)/forum-(\w+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=forumdisplay&fid=$2&page=$3&$5
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$6
RewriteRule ^(.*)/group-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=group&fid=$2&page=$3&$5
RewriteRule ^(.*)/space-(username|uid)-(.+)\.html(\?(.*))*$ $1/home\.php\?mod=space&$2=$3&$5
RewriteRule ^(.*)/([a-z]+)-(.+)\.html(\?(.*))*$ $1/$2\.php\?rewrite=$3&$5
问题解决!
以下是如何在IIS6.0中配置服务器,使IIS支持伪静态
URL 静态化可以提高搜索引擎抓取,开启本功能需要对 Web 服务器增加相应的 Rewrite 规则,且会轻微增加服务器负担。本教程讲解如何在 IIS 环境下配置各个产品的 Rewrite 规则。
一、首先下载 Rewrite.zip 的包,解压到任意盘上的任意目录。
各个产品的 Rewrite 规则包不同,请选择对应的产品下载对应的 Rewrite 规则。
Discuz x1.5/x2/0 的 Rewrite 规则下载地址:Rewrite.zip
下载各个产品的 Rewrite 规则并且重命名后如下图所示存放:

二、配置方法
Discuz!、UCHome、SupeSite/X-Space、SupeV 的 Rewrite 配置方法类似,下面以 Discuz x2.0 的 Rewrite 规则配置方法为例讲解如何在 IIS 环境下配置 Rewrite 规则。
在 IIS 管理器里选择网站,右键选择“属性”,如下图所示:

在弹出的窗口里选择“ISAPI筛选器”

上图中点击“添加”,在弹出的窗口里“筛选器名称”填写“rewrite”

上图界面中点击“浏览”,选择下载解压后的 Discuz! Rewrite 规则目录下的 Rewrite.dll 文件

浏览完毕点击“确定”

添加完毕点击“确定”

重新启动 IIS

重新选择该站点 => 右键“属性”=> “ISAPI 筛选器”,如果看到状态为向上的绿色箭头,就说明 Rewrite 模块安装成功了。
