Discuz! X3.0/X3.1/X3.2通用 伪静态设置和伪静态规则
首先简单讲一下为什么要做伪静态,伪静态是相对真实静态来讲的,通常我们为了增强搜索引擎的友好面,都将文章内容生成静态 页面,但是有的朋友为了实时的显示一些信息。或者还想运用动态脚本解决一些问题。不能用静态的方式来展示网站内容。但是这就损失了对搜索引擎的友好面。怎 么样在两者之间找个中间方法呢,这就产生了伪静态技术。就是展示出来的是以html一类的静态页面形式,这种html的显示形式更加有利于SEO。
现在开源程序越来越流行了,很多新手站长在用Discuz程序搭建网站后,会发现自己的网站地址是动态地址,所谓动态地址就是带有?号这种,比如http://www.xzzbbs.com/forum.php?mod=···这种就属于动态地址,那么,我们想要网站就行伪静态,也就是以html结尾的网址,该如何做呢?
1.在后台“全局》SEO设置》URL 静态化”相关复选框全部勾选,点“提交”按钮。如下图
2.根据web服务器选择相应的伪静态规则:
Apache Web Server(独立主机用户)
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/topic-(.+)\\.html$ $1/portal.php?mod=topic&topic=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/article-([0-9]+)-([0-9]+)\\.html$ $1/portal.php?mod=view&aid=$2&page=$3&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/forum-(\\w+)-([0-9]+)\\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page\\=$4&page=$3&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/group-([0-9]+)-([0-9]+)\\.html$ $1/forum.php?mod=group&fid=$2&page=$3&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/space-(username|uid)-(.+)\\.html$ $1/home.php?mod=space&$2=$3&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/blog-([0-9]+)-([0-9]+)\\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/(fid|tid)-([0-9]+)\\.html$ $1/index.php?action=$2&value=$3&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\\-]+)\\.html$ $1/plugin.php?id=$2:$3&%1
Apache Web Server(虚拟主机用户)
# 将 RewriteEngine 模式打开 RewriteEngine On
# 修改以下语句中的 /discuz 为您的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 / RewriteBase /discuz
# Rewrite 系统规则请勿修改
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^topic-(.+)\\.html$ portal.php?mod=topic&topic=$1&%1 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^article-([0-9]+)-([0-9]+)\\.html$ portal.php?mod=view&aid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^forum-(\\w+)-([0-9]+)\\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^thread-([0-9]+)-([0-9]+)-([0-9]+)\\.html$ forum.php?mod=viewthread&tid=$1&extra=page\\=$3&page=$2&%1 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^group-([0-9]+)-([0-9]+)\\.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-([0-9]+)-([0-9]+)\\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^archiver/(fid|tid)-([0-9]+)\\.html$ archiver/index.php?action=$1&value=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule
^([a-z]+[a-z0-9_]*)-([a-z0-9_\\-]+)\\.html$ plugin.php?id=$1:$2&%1
IIS Web Server(独立主机用户)
[ISAPI_Rewrite]
# 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-([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\\=$4&page