Rewrite兼容设置

作者:zqcheng    发布于7年前 (2011-09-20)    阅读:  304  次

首先,必须确认一下你的站点(DZX)是否已经开启了Rewriter。如果开启了,那么你必须把DZX的规则与Brand的规则(这里是指httpd.ini文件)分别存于服务器的两个目录中,不能在同一个httpd.ini文件包含。
DiscuzX!  httpd.ini

 

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
#DXZ 规则开始
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/topic-(.+).html?*(.*)$ $1/portal.php?mod=topic&topic=$2&$3
RewriteRule ^(.*)/article-([0-9]+)-([0-9]+).html?*(.*)$ $1/portal.php?mod=view&aid=$2&page=$3&$4
RewriteRule ^(.*)/forum-(w+)-([0-9]+).html?*(.*)$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&$4
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html?*(.*)$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3&$5
RewriteRule ^(.*)/group-([0-9]+)-([0-9]+).html?*(.*)$ $1/forum.php?mod=group&fid=$2&page=$3&$4
RewriteRule ^(.*)/space-(username|uid)-(.+).html?*(.*)$ $1/home.php?mod=space&$2=$3&$4
RewriteRule ^(.*)/([a-z]+)-(.+).html?*(.*)$ $1/$2.php?rewrite=$3&$4
#Brand 规则开始
RewriteRule ^(.*)/store-([0-9]+).html?*(.*)$ $1/store.php?id=$2
RewriteRule ^(.*)/store-([0-9]+)-([a-z]+).html?*(.*)$ $1/store.php?id=$2&action=$3
RewriteRule ^(.*)/store-([0-9]+)-([a-z]+)-([0-9]+).html?*(.*)$ $1/store.php?id=$2&action=$3&xid=$4
RewriteRule ^(.*)/store-([0-9]+)-([a-z]+)-catid-([0-9]+).html?*(.*)$ $1/store.php?id=$2&action=$3&catid=$4
RewriteRule ^(.*)/street-([0-9]+).html?*(.*)$ $1/street.php?catid=$2
RewriteRule ^(.*)/street-([0-9]+)-([0-9]+).html?*(.*)$ $1/street.php?catid=$2&tagid=$3

Brand  httpd.ini

 

[ISAPI_Rewrite]
CacheClockRate 3600
RepeatLimit 32
RewriteRule ^(.*)/store-([0-9]+).html?*(.*)$ $1/store.php?id=$2
RewriteRule ^(.*)/store-([0-9]+)-([a-z]+).html?*(.*)$ $1/store.php?id=$2&action=$3
RewriteRule ^(.*)/store-([0-9]+)-([a-z]+)-([0-9]+).html?*(.*)$ $1/store.php?id=$2&action=$3&xid=$4
RewriteRule ^(.*)/store-([0-9]+)-([a-z]+)-catid-([0-9]+).html?*(.*)$ $1/store.php?id=$2&action=$3&catid=$4
RewriteRule ^(.*)/street-([0-9]+).html?*(.*)$ $1/street.php?catid=$2
RewriteRule ^(.*)/street-([0-9]+)-([0-9]+).html?*(.*)$ $1/street.php?catid=$2&tagid=$3

请看我的设置和文件存放:
Snap4.jpg

 

 

图片中的dzrewrite目录为DZX的伪静态httpd.ini及相关动态链接文件(dll)存放目录。
下面的Rewrite为Brand的伪静态httpd.ini及相关动态链接文件(dll)存放目录。

然后再打开WWW目录,把.htaccess文件分别上传到DZX论坛根目录和Brand网站根目录(注意:文件内容不是相同的)。

如下:
DiscuzX!

 

# 将 RewriteEngine 模式打开
RewriteEngine On
# 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
RewriteBase /
# Rewrite 系统规则请勿修改
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^topic-(.+).html$ portal.php?mod=topic&topic=$1&%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 ^([a-z]+)-(.+).html$ $1.php?rewrite=$2&%1

Brand

 

###虚拟主机用户
# 将 RewriteEngine 模式打开
RewriteEngine On
# 修改以下语句中的 /brand 为你的品牌空间目录相对地址,如果程序放在根目录中,请将 /brand 修改为 /
RewriteBase /
# Rewrite 系统规则请勿修改
RewriteRule ^store-([0-9]+).html$ store.php?id=$1 [L,NC]
RewriteRule ^store-([0-9]+)-([a-z]+).html$ store.php?id=$1&action=$2 [L,NC]
RewriteRule ^store-([0-9]+)-([a-z]+)-([0-9]+).html$ store.php?id=$1&action=$2&xid=$3 [L,NC]
RewriteRule ^store-([0-9]+)-([a-z]+)-catid-([0-9]+).html$ store.php?id=$1&action=$2&catid=$3 [L,NC]
RewriteRule ^street-([0-9]+).html$ street.php?catid=$1 [L,NC]
RewriteRule ^street-([0-9]+)-([0-9]+).html$ street.php?catid=$1&tagid=$2 [L,NC]

购买虚拟主机的同学在做以上工作时需要空间商配合。如果是自己的服务器,你自己设置一下就好!!

添加新评论