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 hour CacheClockRate 3600 RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/list-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/portal\.php\?mod=list&catid=$2&page=$3&$5
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 ^(.*)/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伪静态规则
<?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&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^list-([0-9]+)-([0-9]+)\.html$ portal.php?mod=list&catid=$1&page=$2&%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\%3D$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
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;
}

声明:有的资源均来自网络转载,版权归原作者所有,如有侵犯到您的权益 请联系邮箱:123456@qq.com 我们将配合处理!

原文地址:Discuz门户文章列表页伪静态设置教程发布于2023-05-29 07:23:58

相关推荐