PHPwind高级伪静态规则及教程

写在前面的话. PW8 是个里程碑式的版本,有门户,有频道,等多元素多模式组成, stwind高度伪静态(超级伪静态)的处理方法仅仅适用于论坛部分. 并尽力避免与其他操作和地址产生冲突.在这个版本, 改变了几个变量,一个是列表页的变量,一个是过滤特殊字符的变量,  地址组成依然不变, 帖子也依然以 article 为前缀, 列表页以commtopics 链接.pw8里函数改动较大,所以修改也较为麻烦. 考虑到会被任意修改,以后版本考虑单个加密这个文件.  本次依然沿用以前的风格. 
一,打开require/common.php
找到
function urlRewrite($url) {
    global $db_htmifopen, $db_dir, $db_ext;
    if (!$db_htmifopen) return $url;
    $tmppos = strpos($url, '#');
    $add = $tmppos !== false ? substr($url, $tmppos) : '';
    $turl = str_replace(array('.php?', '=', '&', '&', $add), array($db_dir, '-', '-', '-', ''), $url);
    $turl != $url && $turl .= $db_ext;
    return $turl . $add;
}
替换成
function urlRewrite($url) {
    global $db_htmifopen, $db_dir, $db_ext;
    if(strpos($url, 'thread.php?') !== false){
         unset($URL_type);
         $Thread_array = explode('&', substr(str_replace($add, '', $url), 11));
          foreach($Thread_array as $key => $value){
             $URL_array = explode('=', $value, 2);
              if($URL_array['1']){
               switch($URL_array['0']){
                case 'fid':
                    $URL_type['fid'] = $URL_array['1'];
                    $URL_type['type'] < 1 && $URL_type['type'] = 1;
                break;
                case 'page':
                    $URL_type['page'] = $URL_array['1'];
                    $URL_type['type'] < 2 && $URL_type['type'] = 2;
                break;
                default:
                    $URL_type['type'] = 4;
                break;
                }}}
         switch($URL_type['type']){
           case '1':
               $url = "commtopics-" . $URL_type['fid'] ; break;               
           case '2':
               $url = "commtopics-" . $URL_type['fid'] . "-" . $URL_type['page'] ;   break;
             }}elseif(strpos($url, 'read.php?') !== false){
                unset($URL_type);
             $tmppos = strpos($url, '#');
           $add = $tmppos !== false ? substr($url, $tmppos) : '';
              $Read_array = explode('&', substr(str_replace($add, '', $url), 9));
                foreach($Read_array as $key => $value){
                $URL_array = explode('=', $value, 2);
                if($URL_array['1']){
                    switch($URL_array['0']){
                        case 'tid':
                            $URL_type['tid'] = $URL_array['1'];
                            $URL_type['type'] < 1 && $URL_type['type'] = 1;
                            break;
                        case 'page':
                            $URL_type['page'] = $URL_array['1'];
                            $URL_type['type'] < 2 && $URL_type[type] = 2;
                            break;
                        case 'fpage':
                            $URL_type['fpage'] = $URL_array['1'];
                            $URL_type['type'] < 3 && $URL_type['type'] = 3;
                            break;
                        default:
                            $URL_type['type'] = 4;
                            break;
                        }}}
          switch($URL_type['type']){
             case '1':
                 $url = "article-".$URL_type['tid'].".html" ;
                 break;
             case '2':
                 $url = "article-".$URL_type['tid'] . "-" . $URL_type['page'].".html" ;
                 break;
             case '3':
                 $url = "article-". $URL_type['tid'] . "-" . $URL_type['page'] . "-" . $URL_type['fpage'].".html" ;
                 break;
                 }
             }
        //      $url .= $db_ext;  很多人以为后缀问题,故作特处理。
    return $url . $add;
}
规则如下.  添加到httpd.ini或者.htaccess 或者其他

RewriteEngine on
RewriteRule ^thread-htm-tid-(\d+)-(.*).html  thread.php?fid=$1
RewriteRule ^read-htm-tid-(\d+)-(.*).html  read.php?tid=$1
RewriteRule ^commtopics-(\d+)-(.*)  thread.php?fid=$1&page=$2
RewriteRule ^commtopics-(.*)       thread.php?fid=$1&page=$2
RewriteRule ^article-(\d+)-(\d+)-(.*).html  read.php?tid=$1&page=$2&fpage=$3
RewriteRule ^article-(\d+)-(\d+).html       read.php?tid=$1&page=$2
RewriteRule ^article-(.*).html             read.php?tid=$1
RewriteRule ^(.*)-htm-(.*).html    $1.php?$2
RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2

你可能感兴趣的:(PHPwind高级伪静态规则及教程)