xiaoxiao 发表于 2014-10-9 10:44:04

详解如何设置Discuz论坛伪静态

本帖最后由 xiaoxiao 于 2014-10-9 10:54 编辑

进入后台,找到“全局”——“SEO设置”,如图,把右边“可用”下方的框全给勾选


此时你到网站首页,刷新一下,你会看到你的网站地址全变成了伪静态,也就是html结尾的文章或者栏目地址,但是你点进去,会发现出现无法打开页面,是因为你设置了伪静态,却没做伪静态处理,不同的主机,使用不同的伪静态规则才能使之实现伪静态。

如果你的是Apache主机,请把下面代码复制到记事本,保存为.htaccess并上传到空间根目录即可
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.82

# 将 RewriteEngine 模式打开
RewriteEngine On

# 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
RewriteBase /

# Rewrite 系统规则请勿修改
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^article-(+)-(+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^forum-(\w+)-(+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^thread-(+)-(+)-(+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^group-(+)-(+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^blog-(+)-(+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^archiver/(fid|tid)-(+)\.html$ archiver/index.php?action=$1&value=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(+*)-(+)\.html$ plugin.php?id=$1:$2&%1
如果你是IIS主机,复制下面代码到记事本,保存为http.ini然后上传到空间根目录即可


# 3600 = 1 hour
CacheClockRate 3600

RepeatLimit 32

# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/topic-(.+)\.html(\?(.*))*$ $1/portal\.php\?mod=topic&topic=$2&$4
RewriteRule ^(.*)/article-(+)-(+)\.html(\?(.*))*$ $1/portal\.php\?mod=view&aid=$2&page=$3&$5
RewriteRule ^(.*)/forum-(\w+)-(+)\.html(\?(.*))*$ $1/forum\.php\?mod=forumdisplay&fid=$2&page=$3&$5
RewriteRule ^(.*)/thread-(+)-(+)-(+)\.html(\?(.*))*$ $1/forum\.php\?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$6
RewriteRule ^(.*)/group-(+)-(+)\.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 ^(.*)/blog-(+)-(+)\.html(\?(.*))*$ $1/home\.php\?mod=space&uid=$2&do=blog&id=$3&$5
RewriteRule ^(.*)/(fid|tid)-(+)\.html(\?(.*))*$ $1/index\.php\?action=$2&value=$3&$5
RewriteRule ^(.*)/(+*)-(+)\.html(\?(.*))*$ $1/plugin\.php\?id=$2:$3&$5



注意:
.htaccess是无法保存的,因此可以先保存成htaccess。
然后FTP上传至网站跟目录后。修改文件名为.htaccess

如果不生效的话:
1:进入后台,找到“工具”——“更新缓存”
2:重启Apache服务,或者虚拟主机里重启站点








页: [1]
查看完整版本: 详解如何设置Discuz论坛伪静态