Discuz文章列表页伪静态设置教程 [复制链接]
6
0
discuz后台的伪静态配置没有门户频道的伪静态。下面加上这个功能。
第一步:加上语言包中的记录:
根目录下:source/language/lang_admincp.php,找到setting_seo_rewritestatus_portal_article这一行,大概在1500行左右,搜索一下吧。
在这句下面加上一句:
复制代码第二步:在后台加上设置项
根目录下:source/function/function_admincp.php,找到rewritedata函数,在if语句的,两个大括号中,加上下面两段程序
上面一段加上
复制代码下面一段加上
复制代码第三步:兼容栏目页URL地址设置
找到文件:
根目录source/function/function_portal.php下的函数getportalcategoryurl
重新写成下面的代码:
复制代码第四步:设置前台页面URL地址切换
根目录source/function/function_core.php这个文件中找到:函数rewriteoutput
在一串的if ... else if中加上一段
复制代码IIS6伪静态规则:
复制代码IIS7伪静态规则
第一步:加上语言包中的记录:
根目录下: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>
找到文件:
根目录source/function/function_portal.php下的函数getportalcategoryurl
重新写成下面的代码:
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">function getportalcategoryurl($catid) {</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> if (empty($catid))</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> return '';</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> loadcache('portalcategory');</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> $portalcategory = getglobal('cache/portalcategory');</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> if ($portalcategory[$catid]) {</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> $url = str_replace('&', '&', $portalcategory[$catid]['caturl']);</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> $url = str_replace('&', '&', $url);</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> $url = str_replace('http://'.$_SERVER['HTTP_HOST'].'/', '', $url);</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> return $url;</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> } else {</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> return '';</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;"> }</span>
- <span style="font-family: Tahoma, 'Microsoft Yahei', Simsun;">}</span>
根目录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>
- [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
- <?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>
-
历史资源提醒--必看
该页面资源/教程来自原魔趣吧历史资源转移,因发布历史久远,部分资源/教程可能已失效或无法在最新版程序中安装使用!DZ资源建议在Discuz3.4及以下版本使用,PHP版本建议5.6。资源仅提供做代码研究学习使用!
因改版,部分贴内链接将无法正常跳转,如链接失效或未正常跳转,请利用站内搜索功能搜索资源名称获取对应资源!
最新回复 (0)