A-A+

Discuz! X2 各种类型伪静态规则

2013年08月07日 Discuz 暂无评论 阅读 257 次浏览 次
Crossday Discuz! Board(简称 Discuz!)是北京康盛新创科技有限责任公司推出的一套通用的社区论坛软件系统。自2001年6月面世以来,Discuz!已拥有12年以上的应用历史和200多万网站用户案例,是全球成熟度最高、覆盖率最大的论坛软件系统之一。目前最新版本Discuz! X3.1正式版于2013年9月23日发布,首次引入应用中心的开发模式。2010年8月23日,康盛创想与腾讯达成收购协议,成为腾讯的全资子公司。
 
首先确定您使用的 Apache 版本,及是否加载了 mod_Rewrite 模块。 
Apache 1.x 的用户请检查 conf/httpd.conf 中是否存在如下两段代码: 
LoadModule Rewrite_module libexec/mod_Rewrite.so
AddModule mod_Rewrite.c Apache 2.x 的用户请检查 conf/httpd.conf 中是否存在如下一段代码: 
LoadModule Rewrite_module modules/mod_Rewrite.so
如果存在,那么在配置文件(通常就是 conf/httpd.conf)中加入如下代码。此时请务必注意,如果网站使用通过虚拟主机来定义,请务必加到虚拟主机配置,即 <VirtualHost> 中去,如果加在虚拟主机配置外部将可能无法使用,改好后将 Apache 重启。
 
###Apache Web Server伪静态设置:
检查论坛所在目录中是否存在 .htaccess 文件,如果不存在,请手工建立此文件。Win32 系统下,无法直接建立 .htaccess 文件,您可以从其他系统中拷贝一份,编辑并修改 .htaccess 文件,添加以下内容:
# 将 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 ^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 ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
 
###IIS 6.0伪静态:
1.下载ISAPI_Rewrite组建放到网站根目录下,http://www.discuz.net/forum.php? ... Tc3MDF8MHwyMjExMDg1,里面一般包含,规则文件(httpd.ini),伪静态需要加载的dll文件(Rewrite.dll)
2.找到要设置的网站右键-属性-ISAPI筛选器,筛选器名称如:re,可执行文件选择ISAPI_Rewrite组建里面的,通常名为Rewrite.dll。
3.重启iis。
 
###IIS7伪静态:
可以将如下的配置规则加入到 web.config 中
 
<rewrite>
<rules>
  <rule name="portal_topic">
   <match url="^(.*/)*topic-(.+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/portal.php\?mod=topic&topic={R:2}&{R:3}" />
  </rule>
  <rule name="forum_forumdisplay">
   <match url="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$" />
   <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\?*(.*)$" />
   <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\?*(.*)$" />
   <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\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/home.php\?mod=space&{R:2}={R:3}&{R:4}" />
  </rule>
  <rule name="forum_archiver">
   <match url="^(.*/)*(fid|tid)-([0-9]+).html\?*(.*)$" />
   <action type="Rewrite" url="{R:1}/index.php\?action={R:2}&value={R:3}&{R:4}" />
  </rule>
</rules>
</rewrite>
 
###Zeus Web Server
配置规则如下:
 
match URL into $ with ^(.*)/topic-(.+)\.html\?*(.*)$
if matched then
set URL = $1/portal.php?mod=topic&topic=$2&$3
endif
match URL into $ with ^(.*)/forum-(\w+)-([0-9]+)\.html\?*(.*)$
if matched then
set URL = $1/forum.php?mod=forumdisplay&fid=$2&page=$3&$4
endif
match URL into $ with ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html\?*(.*)$
if matched then
set URL = $1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$5
endif
match URL into $ with ^(.*)/group-([0-9]+)-([0-9]+)\.html\?*(.*)$
if matched then
set URL = $1/forum.php?mod=group&fid=$2&page=$3&$4
endif
match URL into $ with ^(.*)/space-(username|uid)-(.+)\.html\?*(.*)$
if matched then
set URL = $1/home.php?mod=space&$2=$3&$4
endif
match URL into $ with ^(.*)/(fid|tid)-([0-9]+)\.html\?*(.*)$
if matched then
set URL = $1/index.php?action=$2&value=$3&$4
endif
 
###Nginx Web Server
配置规则如下:
 
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 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 ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
if (!-e $request_filename) {
return 404;
}

 

标签:

评论已关闭!

Copyright © 香港虚拟主机_美国虚拟主机_香港服务器_美国服务器租用托管 保留所有权利.   Theme  Ality 蜀ICP备14006632号-1

用户登录