• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
骨头
各位大哥,请发帖提问,短信回答太局限,拒绝回答鸟~!~
级别: 管理员
楼主  发表于: 2008-07-21 11:32

 解除转换后的流量丢失之——全面Rewrite规则

管理提醒:
本帖被 骨头 执行加亮操作(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]


Copy code
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]


老版本如果不能实现伪静态,可以尝试一下规则
Copy code
RewriteRule ^(.*)-htm-(.*)$   $1\.php\?$2
RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html [NC]

然后重启IIS或者apache.



或者用下面
Copy code
<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的伪静态

Copy code
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
Copy code
[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
Copy code
<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转换过来的
Copy code
<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转换过来的
Copy code
<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转换过来的
Copy code
<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>




  下帖讲无独立服务器权限的。
本帖最近评分记录:
  • 威望:+1(gamemx) 本人试过了作用不大,对 ..
  • 威望:+5(小猴) 优秀文章-欢迎进行技术交 ..
  • 威望:+3(灰机) 您怎么啥都会?
  • 威望:+10(大力) 甚、强、巨、大、猛!!!
  • 威望:+5(慕容暖暖) 很强大
  • 金钱:+11(MGarfield) 优秀文章-欢迎进行技术交 ..
  • 搜索更多相关文章:rewrite 服务器 PHP 流量 静态
    骨头
    各位大哥,请发帖提问,短信回答太局限,拒绝回答鸟~!~
    级别: 管理员
    1楼  发表于: 2008-07-21 11:33
    本楼说说,无独立服务器权限的做法:

    分两种情况,一是支持.htaccess,一种是不支持伪静态的虚拟空间。
    对于支持.htaccess的空间,可以套用转发规则进行处理.

    无法用重写的,我们用文件来补救

    DZ:
    把thread.php复制一份改名为forumdisplay.php
    把read.php复制一份改名为viewthread.php


    这样省事省时,哈哈,祝大家愉快!

    DVBBS:
    如果你的服务器还支持ASP的话
    可以在index.asp和dispbbs.asp上面做下。

    更可科学的方法还待研究,欢迎我的砖头(抛砖引玉),更渴望大家把玉扔出来分享



    。。。。。。。。。。
    tydf
    每天到PHPWIND学习
    级别: 商业版用户
    模范会员奖
    2楼  发表于: 2008-07-21 11:34
    老大,是强人啊
    龙文
    (#‵′)凸  o(︶︿︶)o  ╮(╯_╰)╭
    级别: 论坛版主
    风格大师奖
    3楼  发表于: 2008-07-21 11:35
    好强大~~~
    慕容暖暖
    九点钟·····
    级别: 论坛版主
    优秀版主奖 热心助人奖
    4楼  发表于: 2008-07-21 11:36
    支持
    iceleaf
    只想找个妹妹抱着睡!~~还是迷糊点好!我不是马甲~~
    级别: PW官方侠客
    5楼  发表于: 2008-07-21 11:36
       骨头`
    有四片的叶子吗!?~

    PW官方第二帅的帅哥~^_^

    本人小站:安昌古镇
    lyn
    冤家宜解不宜结~
    级别: 总版主
    优秀版主奖 热心助人奖
    6楼  发表于: 2008-07-21 11:37
    支持。。。。。。。
    MGarfield
    我们不是在对个别人作战,而是在将资产阶级作为一个阶级消灭。
    级别: PW官方团队
    7楼  发表于: 2008-07-21 11:37
    混个第一页。支持骨头
    国内首款php开源DIGG系统
    PBDiggpbdigg.com 免费 & 开源


    大力
    猪肉像花儿一样
    级别: PW官方团队
    8楼  发表于: 2008-07-21 11:40
    猛的~
    私家车107、快乐广播、城市之声  |  S.T:站长论坛  |  doeee.com
    ------------------------------------------------------------------------------------------------------
    每天早上起床我都要先看福布斯富翁排行榜,如果上面没有我的名字,我就去上班..
    灰机
    灰机又来了!!!
    级别: 四星会员
    9楼  发表于: 2008-07-21 11:40

    传说中的全才!
    再指指点点的,当心灰下来砸死你
    vc演示站:www.bencp.com
    魅惑乐趣
    用户消失
    级别: 论坛版主
    优秀版主奖 热心助人奖 插件大师奖
    10楼  发表于: 2008-07-21 12:08
    哦。哦。哦。哦。
    terrygyd
    凡人不做凡事
    级别: PW官方侠客
    11楼  发表于: 2008-07-21 12:12
    顶一个。。。
    &×%¥¥%#……&×(
    婉如清风
    再说一次.我是男生!!
    级别: 论坛版主
    模范会员奖
    12楼  发表于: 2008-07-21 12:14
    支持.
    小猴
    administrator
    级别: 论坛版主
    13楼  发表于: 2008-07-21 13:07
    支持,zeus的有没有???
    在线数百人,会员十五W的游戏论坛招相关友情链接 联系qq:961460580
    在线数百人,会员十五W的游戏论坛招相关友情链接 联系qq:961460580
    承接linux服务器WEB环境构架及优化,让你的论坛速度飞起来 请联系我的QQ:694568
    小猴
    administrator