管理提醒:
本帖被 骨头 执行加亮操作(2008-07-21)
之前写过一个
PHPWind保持Dz转换后的搜索引擎带来的流量之rewrite 规则 ,当时对此方面知识尚未深刻了解,局限性太强,今天就全面的写下转换后的几个rewriterule。
主要以这么5个Discuz!,DVBBS,LEOBBS,LEADBBS,BBSXP,,需要更多可以提出来,我帮你写,或者根据这个思路逐渐
修改。
参考资料:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html 欢迎大家一起来~!~
我的平台是 Apache/2.2.4 (Win32) ,IIS的伪
静态规则和apache可以通用, zeus和Nginx规则有些变化,但用的人比较少后面有时间再讲
先针对的是有独立主机权限的用户请注意,高级重写(
要写绝对目录,这里举例用/bbs/,请根据实际情况更改):
DZ转换过来的。~【有独立服务器的站长,重写规则出错可以找官方侠客,或者找PM我一起解决】请先做一下步骤:
把thread.php复制一份改名为forumdisplay.php
把read.php复制一份改名为viewthread.php 这样省事省时,保证动态地址访问正常,接下去开始伪静态重写规则
RewriteRule ^(.*)/archiver/$ [R]
用
复制代码- # 适用于.htaccess和httpd.conf
- RewriteEngine On
- RewriteRule ^(.*)/archiver/ /simple/ [R]
- RewriteRule ^(.*)/tid-(\d+)\.html /simple/index.php?t$2.html [R]
- RewriteRule ^(.*)/fid-(\d+)\.html /simple/index.php?f$2.html [R]
- RewriteRule ^(.*)/fid-(\d+)-(\d+)-1.html /simple/index.php?f$2.html [R]
- RewriteRule ^(.*)/forum-(\d+)-(\d+)\.html$ $1/thread.php?fid=$2 [R]
- RewriteRule ^(.*)/thread-(\d+)-(\d+)-(\d+)\.html$ $1/read.php?tid=$2 [R]
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC,L]
|
老版本如果不能实现伪静态,可以尝试一下规则复制代码- # httpd.ini 在Rewrite的不同版本
- RewriteRule ^(.*)-htm-(.*)$ $1\.php\?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC]
|
然后重启IIS或者apache.
或者用下面
复制代码- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/forumdisplay.php$ [OR]
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/viewthread.php$ [NC]
- RewriteCond %{QUERY_STRING} fid=(\d+) [OR]
- RewriteCond %{QUERY_STRING} tid=(\d+) [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/fid=(\d+) /bbs/thread.php?fid=$1 [R]
- RewriteRule ^/tid=(\d+) /bbs/read.php?tid=$1 [R]
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/archiver/$ [NC]
- RewriteCond %{QUERY_STRING} tid-(\d+).html [OR]
- RewriteCond %{QUERY_STRING} fid-(\d+).html [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/tid-(\d+).html /bbs/simple/index.php?t$1.html [R]
- RewriteRule ^/fid-(\d+).html /bbs/simple/index.php?f$1.html [R]
- RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/thread.php?fid=$2
- RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/read.php?tid=$2
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC,L]
- </IfModule>
|
ZUes的伪静态
复制代码- match URL into ^(.*)/forum-([0-9]+)-([0-9]+)\.html$
- if matched then
- set URL = $1/thread.php?fid=$2
- endif
- match URL into $ with ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$
- if matched then
- set URL = $1/read.php?tid=$2
- endif
- match URL into $ with ^(.*)-htm-(.*)$
- if matched then
- set URL = $1.php?$2
- endif
- match URL into $ with ^(.*)/simple/([a-z0-9\_]+\.html)$
- if matched then
- set URL = $1/simple/index.php?$2
- endif
|
DVBBS转换过来的
1\IIS的httpd.ini
复制代码- [ISAPI_Rewrite]
- RewriteEngine On
- CacheClockRate 3600
- RepeatLimit 32
- RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
- RewriteRule ^(.*)/dispbbs.asp\?boardid=(\d+)&Id=(\d+) $1/read.php?tid=$3 [NC]
- RewriteRule ^(.*)/dispbbs.asp\?boardid=(\d+)&id=(\d+) $1/read.php?tid=$3 [R]
- RewriteRule ^(.*)/dispbbs.asp\?BoardID=(\d+)&Id=(\d+) $1/read.php?tid=$3 [R]
- RewriteRule ^(.*)/index.asp\?boardid=(\d+) $1/thread.php?fid=$2 [R]
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC,L]
- #Code By Josh @ PHPWind 2008-09-25 ?([a-zA-Z]+)
|
2、apache
复制代码- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/index.asp$ [NC]
- RewriteCond %{QUERY_STRING} boardid=(\d+)$ [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/boardid=(\d+)$ /bbs/thread.php?fid=$1 [R]
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/dispbbs.asp$ [NC]
- RewriteCond %{QUERY_STRING} boardid=(\d+)&Id=(\d+) [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/boardid=(\d+)&Id=(\d+) /bbs/read.php?tid=$2 [R]
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC,L]
- </IfModule>
|
LEOBBS转换过来的
复制代码- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/cgi-bin/forums.cgi$ [NC]
- RewriteCond %{QUERY_STRING} forum=(\d+)$ [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/forum=(\d+)$ /bbs/thread.php?fid=$1 [R]
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/cgi-bin/topic.cgi$ [NC]
- RewriteCond %{QUERY_STRING} forum=(\d+)&topic=(\d+) [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/forum=(\d+)&topic=(\d+) /bbs/read.php?tid=$2 [R]
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC,L]
- </IfModule>
|
BBSXP转换过来的
复制代码- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/ShowForum.asp$ [NC]
- RewriteCond %{QUERY_STRING} ForumID=(\d+) [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/ForumID=(\d+) /bbs/thread.php?fid=$1 [R]
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/ShowPost.asp$ [NC]
- RewriteCond %{QUERY_STRING} ThreadID=(\d+) [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/ThreadID=(\d+) /bbs/read.php?tid=$1 [R]
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC,L]
- </IfModule>
|
LEADBBS转换过来的
复制代码- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/b/b.asp$ [NC]
- RewriteCond %{QUERY_STRING} B=(\d+) [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/B=(\d+) /bbs/thread.php?fid=$1 [R]
- RewriteCond %{SCRIPT_FILENAME} ^/bbs/a.asp$ [NC]
- RewriteCond %{QUERY_STRING} B=(\d+)&ID=(\d+) [NC]
- RewriteRule (.*) /%{QUERY_STRING} [NC]
- RewriteRule ^/B=(\d+)&ID=(\d+) /bbs/read.php?tid=$2 [R]
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC,L]
- </IfModule>
|
下帖讲无独立服务器权限的。