Apache独立主机rewrite规则
设置步骤如下:
1、首先确定您使用的 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
2、如果存在,那么在配置文件(通常就是 conf/httpd.conf)中加入如下代码。改好后然后将 Apache 重启。
引用:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/archiver/((fid|tid)-[0-9]+\.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3
RewriteRule ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2
RewriteRule ^/([0-9]+)/spacelist(.+)$ /index.php?uid/$1/action/spacelist/type$2 [L]
RewriteRule ^/([0-9]+)/viewspace(.+)$ /index.php?uid/$1/action/viewspace/itemid$2 [L]
RewriteRule ^/([0-9]+)/viewbbs(.+)$ /index.php?uid/$1/action/viewbbs/tid$2 [L]
RewriteRule ^/([0-9]+)/(.*)$ /index.php?uid/$1/$2 [L]
RewriteRule ^/([0-9]+)$ /index.php?uid/$1 [L]
RewriteRule ^/action(.+)$ /index.php?action$1 [L]
RewriteRule ^/category(.+)$ /index.php?action/category/catid$1 [L]
RewriteRule ^/viewnews(.+)$ /index.php?action/viewnews/itemid$1 [L]
RewriteRule ^/viewthread(.+)$ /index.php?action/viewthread/tid$1 [L]
RewriteRule ^/mygroup(.+)$ /index.php?action/mygroup/gid$1 [L]
</IfModule>
注意:将LoadModule rewrite_module modules/mod_rewrite.so前的#号去掉!!
如果没有安装 mod_rewrite,linux服务器您可以重新编译 Apache,并在原有 configure 的内容中加入 --enable-rewrite=shared,然后再在 Apache 配置文件中加入上述代码即可。
win服务器,直接在httpd.conf里添加
LoadModule rewrite_module modules/mod_rewrite.so
3、注意,如上红色部分需要根据您安装SupeSite的路径进行调整,调整方法如下:
引用:
如果您的SupeSite需要域名后面加目录名的方式才可以访问,那么,您需要手工修改以下规则:
将 “^/” 修改为 “^/xxx/”
将 “/index.php” 修改为 “/xxx/index.php”
其中,xxx 为您的程序目录名
最后标注一下:在以上的Rewrite规则里,黑色部分是DZ的Rewrite规则,红色是SupeSite/X-Space的Rewrite规则!
[
本帖最后由 安笛 于 2007-7-27 15:45 编辑 ]