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(独立主机用户)
<IfModule mod_rewrite.c>
RewriteEngine On
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\%3D$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
</IfModule>
Apache Web Server(虚拟主机用户)
#将RewriteEngine模式打开
RewriteEngine On
#修改以下语句中的/discuz为您的论坛目录地址如果程序放在根目录中请将/discuz修改为/
RewriteBase /discuz
# Rewrite系统规则请勿修改
RewriteCond %{QUERY_STRING} ^ (.*)$
RewriteRule
^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1RewriteCond %{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} ^ (.*)$
RewriteRulejwWm
^thread-( [0-9]+)-( [0-9]+)-( [0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
RewriteCond %{QUERY_STRING} ^ (.*)$
RewriteRule
^group-( [0-9]+)-( [0-9]+)\.html$ forum.php?mod=group&f id=$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\%3D$4&page
=$3&$6
RewriteRule
^ (.*)/group-( [0-9]+)-( [0-9]+)\.html (\?(.*) )*$ $1/forum\.php\?mod=group&f id=$2&page=$3&$5
RewriteRule
^ (.*)/space-(username|uid)-(.+)\.html (\?(.*) )*$ $1/home\.php\?mod=space&$2=$3&$5
RewriteRule
^ (.*)/blog-( [0-9]+)-( [0-9]+)\.html (\?(.*) )*$ $1/home\.php\?mod=space&uid=$2&do=blog&id=$3&$5
RewriteRule
^ (.*)/(fid|tid)-( [0-9]+)\.html (\?(.*) )*$ $1/index\.php\?action=$2&value=$3&$5
RewriteRule
^ (.*)/( [a-z]+[a-z0-9_]*)-( [a-z0-9_\-]+)\.html (\?(.*) )*$ $1/plugin\.php\?id=$2:$3&$5
IIS7 Web Server(独立主机用户)
<rewrite>
<rules>
<rule name="portal_topic">
<matchurl="^ (.*/)*topic-(.+) .html\?*(.*) [ DISCUZ_CODE_2
]quot; />
<action type="Rewrite"url="{R: 1}/portal.php\?mod=topic&topic={R:2}&{R:3}" />
</rule>
<rule name="portal_article">
<matchurl="^ (.*/)*article-( [0-9]+)-( [0-9]+) .html\?*(.*) [DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/portal.php\?mod=view&aid={R:2}&page={R:3}&{R:4}" />
</rule>
<rule name="forum_forumdisplay">
<matchurl="^ (.*/)*forum-(\w+)-( [0-9]+) .html\?*(.*) [ DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/forum.php\?mod=forumdisplay&fid={R:2}&page={R:3}&{R:4}" />
</rule>
<rule name="forum_viewthread">
jwWm
<matchurl="^ (.*/)*thread-( [0-9]+)-( [0-9]+)-( [0-9]+) .html\?*(.*)[ DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/forum.php\?mod=viewthread&tid={R:2}&extra=page%3D{R:4}&page={R:3}&{R:5}" />
</rule>
<rule name="group_group">
<matchurl="^ (.*/)*group-( [0-9]+)-( [0-9]+) .html\?*(.*) [ DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/forum.php\?mod=group&f id={R:2}&page={R:3}&{R:4}" />
</rule>
<rule name="home_space">
<matchurl="^ (.*/)*space-(username|uid)-(.+) .html\?*(.*) [
DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/home.php\?mod=space&{R:2}={R:3}&{R:4}" />
</rule>
<rule name="home_blog">
<matchurl="^ (.*/)*blog-( [0-9]+)-( [0-9]+) .html\?*(.*) [ DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/home.php\?mod=space&uid={R:2}&do=blog&id={R:3}&{R:4}" />
</rule>
<rule name="forum_archiver">
<matchurl="^ (.*/)*(fid|tid)-( [0-9]+) .html\?*(.*) [ DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/index.php\?action={R:2}&value={R:3}&{R:4}" />
</rule>
<rule name="plugin">
<matchurl="^ (.*/)*( [a-z]+[a-z0-9_]*)-( [a-z0-9_\-]+) .html\?*(.*)[ DISCUZ_CODE_2 ]quot; />
<action type="Rewrite"url="{R: 1}/plugin.php\?id={R:2} : {R:3}&{R:4}" />
</rule>
</rules>
</rewrite>
Zeus Web Servermatch URL into $ with ^ (.*)/topic-(.+)\.html\?*(.*)$if matched thenset URL = $1/portal.php?mod=topic&topic=$2&$3endifmatch URL into $ with
^ (.*)/article-( [0-9]+)-( [0-9]+)\.html\?*(.*)$if matched thenset URL= $1/portal.php?mod=view&aid=$2&page=$3&$4endifmatch URL into $ with
^ (.*)/forum-(\w+)-( [0-9]+)\.html\?*(.*)$if matched thenset URL =
$1/forum.php?mod=forumdisplay&f id=$2&page=$3&$4endifmatch URL into $ with
^ (.*)/thread-( [0-9]+)-( [0-9]+)-( [0-9]+)\.html\?*(.*)$if matched thenset URL =
$1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$5endifmatch URL into $ with
^ (.*)/group-( [0-9]+)-( [0-9]+)\.html\?*(.*)$if matched thenset URL= $1/forum.php?mod=group&fid=$2&page=$3&$4endifmatch URL into $ with
^ (.*)/space-(username|uid)-(.+)\.html\?*(.*)$if matched thenset URL = $1/home.php?mod=space&$2=$3&$4endifmatch URL into $ with
^ (.*)/blog-( [0-9]+)-( [0-9]+)\.html\?*(.*)$if matched thenset URL =
$1/home.php?mod=space&uid=$2&do=blog&id=$3&$4endifmatch URL into $ with
^ (.*)/(fid|tid)-( [0-9]+)\.html\?*(.*)$jwWm
if matched thenset URL = $1/index.php?action=$2&value=$3&$4endifmatch URL into $ with
^ (.*)/( [a-z]+[a-z0-9_]*)-( [a-z0-9_\-]+)\.html\?*(.*)$if matched thenset URL = $1/plugin.php?id=$2:$3&$4endif
Nginx Web Serverrewrite
^ ( [^\. ]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;rewrite
^ ( [^\. ]*)/article-( [0-9]+)-( [0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;rewrite
^ ( [^\. ]*)/forum-(\w+)-( [0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;rewrite
^ ( [^\. ]*)/thread-( [0-9]+)-( [0-9]+)-( [0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;rewrite
^ ( [^\. ]*)/group-( [0-9]+)-( [0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;rewrite
^ ( [^\. ]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;rewrite
^ ( [^\. ]*)/blog-( [0-9]+)-( [0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;rewrite
^ ( [^\. ]*)/(fid|tid)-( [0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;rewrite
^ ( [^\. ]*)/( [a-z]+[a-z0-9_]*)-( [a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;if (!-e $request_filename) {return 404;
}
3.在网站根目录建立.htaccess文件把伪静态规则复制进去保存。
PS部分伪静态规则里有目录选择默认目录是/discuz如果其他目录的话修改第2行“RewriteBase /discuz” 把discuz换成目录名,如在bbs目录则改为
RewriteBase /bbs .htaccess文件放在bbs目录
附上新站长论坛所使用的伪静态规则一般站点都可以使用。[attach]41 [/attach]jwWm
青果网络QG.NET定位为高效多云管理服务商,已拥有工信部颁发的全网云计算/CDN/IDC/ISP/IP-VPN等多项资质,是CNNIC/APNIC联盟的成员之一,2019年荣获国家高薪技术企业、福建省省级高新技术企业双项荣誉。那么青果网络作为国内主流的IDC厂商之一,那么其旗下美国洛杉矶CN2 GIA线路云服务器到底怎么样?官方网站:https://www.qg.net/CPU内存系统盘流量宽带...
RAKsmart 商家八月份的促销活动今天更新。基本上和上个月的产品套餐活动差不多的,不过也是有简单的微调。对于RAKsmart商家还是比较了解的,他们家产品虽然这两年增加多个机房,以及在VPS主机方案上有丰富的机房和调整到一些自营机房,他们家的策划能力还是有限,基本上每个月的套餐活动都差不多。RAKsmart 在八月份看到有新增香港高防服务器可选,最高100GB防御。同时原来上个月缺货的日本独立...
10gbiz怎么样?10gbiz 美国万兆带宽供应商,主打美国直连大带宽,真实硬防。除美国外还提供线路非常优质的香港、日本等数据中心可供选择,全部机房均支持增加独立硬防。洛杉矶特色线路去程三网直连(电信、联通、移动)回程CN2 GIA优化,全天低延迟。中国大陆访问质量优秀,最多可增加至600G硬防。香港七星级网络,去程回程均为电信CN2 GIA+联通+移动,大陆访问相较其他香港GIA线路平均速度更...