注册 | 登录 |
地方论坛门户及新闻和人才网址大全

Discuz门户文章列表页伪静态设置教程

时间:2021-07-21人气:-


discuz后台的伪静态配置没有门户频道的伪静态。下面加上这个功能。第一步:加上语言包中的记录:根目录下:source/language/lang_admincp.php,找到setting_seo_rewritestatus_portal_article这一行,大概在1500行左右,搜索一下吧。在这句下面加上一句:'setting_seo_rewritestatus_portal_list' => '门户频道页',复制代码第二步:在后台加上设置项根目录下:source/function/function_admincp.php,找到rewritedata函数,在if语句的,两个大括号中,加上下面两段程序上面一段加上
<span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">      if (in_array('portal_list', $_G['setting']['rewritestatus'])) {</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">            $data['search']['portal_list'] = "/" . $_G['domain']['pregxprw']['portal'] . "?mod=list&(amp;)?catid=(d+)(&page=(d+))?"([^>]*)>/e";</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">            $data['replace']['portal_list'] = "rewriteoutput('portal_list', 0, '\1', '\3', '\5', '\6')";</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        }</span>
下面一段加上
<span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        $data['rulesearch']['portal_list'] = 'list-{catid}-{page}.html';</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        $data['rulereplace']['portal_list'] = 'portal.php?mod=list&catid={catid}&page={page}';</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        $data['rulevars']['portal_list']['{catid}'] = '([0-9]+)';</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        $data['rulevars']['portal_list']['{page}'] = '([0-9]+)';</span>
第三步:兼容栏目页URL地址设置找到文件:根目录source/function/function_portal.php下的函数getportalcategoryurl重新写成下面的代码:第四步:设置前台页面URL地址切换根目录source/function/function_core.php这个文件中找到:函数rewriteoutput在一串的if ... else if中加上一段
<span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">elseif ($type == 'portal_list') {</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        list(,,, $id, $page, $extra) = func_get_args();</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        $r = array(</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">            '{catid}' => $id,</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">            '{page}' => $page ? $page : 1,</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">        );</span><span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">    }</span>
IIS6伪静态规则:[ISAPI_Rewrite]# 3600 = 1 hourCacheClockRate 3600RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files# from accessing through HTTPRewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^(.*)/list-([0-9]+)-([0-9]+).html(?(.*))*$ $1/portal.php?mod=list&catid=$2&page=$3&$5RewriteRule ^(.*)/topic-(.+).html(?(.*))*$ $1/portal.php?mod=topic&topic=$2&$4RewriteRule ^(.*)/article-([0-9]+)-([0-9]+).html(?(.*))*$ $1/portal.php?mod=view&aid=$2&page=$3&$5RewriteRule ^(.*)/forum-(w+)-([0-9]+).html(?(.*))*$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&$5RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html(?(.*))*$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3&$6RewriteRule ^(.*)/group-([0-9]+)-([0-9]+).html(?(.*))*$ $1/forum.php?mod=group&fid=$2&page=$3&$5RewriteRule ^(.*)/space-(username|uid)-(.+).html(?(.*))*$ $1/home.php?mod=space&$2=$3&$5RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+).html(?(.*))*$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&$5RewriteRule ^(.*)/(fid|tid)-([0-9]+).html(?(.*))*$ $1/index.php?action=$2&value=$3&$5RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html(?(.*))*$ $1/plugin.php?id=$2:$3&$5复制代码IIS7伪静态规则<?xml version="1.0" encoding="UTF-8"?><configuration>    <system.webServer>                <rewrite>                        <rules>                                <rule name="portal_topic">                                        <match url="^(.*/)*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_list">                                        <match url="^(.*/)*list-([0-9]+)-([0-9]+).html?*(.*)[        DISCUZ_CODE_2        ]quot; />                                        <action type="Rewrite" url="{R:1}/portal.php?mod=list&catid={R:2}&page={R:3}&{R:4}" />                                </rule>                                <rule name="portal_article">                                        <match url="^(.*/)*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">                                        <match url="^(.*/)*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">                                        <match url="^(.*/)*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">                                        <match url="^(.*/)*group-([0-9]+)-([0-9]+).html?*(.*)[        DISCUZ_CODE_2        ]quot; />                                        <action type="Rewrite" url="{R:1}/forum.php?mod=group&fid={R:2}&page={R:3}&{R:4}" />                                </rule>                                <rule name="home_space">                                        <match url="^(.*/)*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">                                        <match url="^(.*/)*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">                                        <match url="^(.*/)*(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">                                        <match url="^(.*/)*([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>   </system.webServer>         </configuration>
APACH伪静态规则# 将 RewriteEngine 模式打开RewriteEngine On# 修改以下语句中的 /RewriteBase /discuz 为您的论坛目录地址,如果程序放在根目录中,请将 /RewriteBase /discuz 修改为 /RewriteBase /discuz
# Rewrite 系统规则请勿修改RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^topic-(.+).html$ portal.php?mod=topic&topic=$1&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^list-([0-9]+)-([0-9]+).html$ portal.php?mod=list&catid=$1&page=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^article-([0-9]+)-([0-9]+).html$ portal.php?mod=view&aid=$1&page=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^forum-(w+)-([0-9]+).html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ forum.php?mod=viewthread&tid=$1&extra=page%3D$3&page=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^group-([0-9]+)-([0-9]+).html$ forum.php?mod=group&fid=$1&page=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^space-(username|uid)-(.+).html$ home.php?mod=space&$1=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^blog-([0-9]+)-([0-9]+).html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^archiver/(fid|tid)-([0-9]+).html$ archiver/index.php?action=$1&value=$2&%1RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ plugin.php?id=$1:$2&%1
Nginx伪静态规则
rewrite ^([^.]*)/list-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=list&catid=$2&page=$3 last;rewrite ^([^.]*)/topic-(.+).html$ $1/portal.php?mod=topic&topicid=$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;}


上篇:discuz 3.2 div显示/隐藏代码

下篇:Discuz!x修改为固定网站标识干扰码的方法