phpwind8.7仿discuz伪静态规则实现方法
首页 > 资源分享   作者:haofeng  2020年11月7日 15:58 星期六  热度:140°  字号:   评论: 
时间:2020-11-7 15:58   热度:140°  评论:0 条 

老古董phpwind8.7应该还有很多老站在使用吧?

没有一定功底的站长基本不会去转换了吧?为了医护的幸福生活 转DZ吧!!不会? 我也不转过,那就先把链接url 换成DZ的吧。

修改 pw的伪静态。最主要是把板块forum和内容thread 两条修改进去。

Nginx规则:

rewrite /forum-(\d+)-(.*)-(.*).html$ /thread.php?fid=$1&page=$2&type=$3 last;
rewrite /forum-(\d+)-(.*)-1.html$ /thread.php?fid=$1&page=$2 last;
rewrite /forum-(\d+)-1-1.html$ /thread.php?fid=$1&page=$2 last;
rewrite /thread-(\d+)-(.*)-(.*)-(.*).html$ /read.php?tid=$1&page=$2&fpage=$3&uid=$4 last;
rewrite /thread-(\d+)-(.*)-(.*).html$ /read.php?tid=$1&page=$2&fpage=$3 last;
rewrite /thread-(\d+)-(.*)-1.html$ /read.php?tid=$1&page=$2 last;
rewrite /thread-(\d+)-1-1.html$ /read.php?tid=$1 last;
rewrite ^/(.*)-htm-(.*)$ /$1.php?$2 last;
rewrite /simple/([a-z0-9\_]+)\.html$ /simple/index\.php\?$1 last;

 打开文件require/common.php,找到function urlRewrite($url) 函数,把函数代码替换成如下代码:

function urlRewrite($url) {
global $db_htmifopen, $db_dir, $db_ext;
if (!$db_htmifopen) return $url;
     if (!preg_match('/^(http|ftp|telnet|mms|rtsp)|admin.php|rss.php/i', $url)){
         $add = strpos($url, '#') !== false ? substr($url, strpos($url, '#')) : '';
         if(strpos($url, 'thread.php?') !== false){
             unset($rw);
             $tharr = explode('&', substr(str_replace($add, '', $url), 11));
             foreach($tharr as $key => $value){
                 $ru = explode('=', $value, 3);
                 if($ru['1']){
                     switch($ru['0']){
                     case 'fid':
                         $rw['fid'] = $ru['1'];
                         $rw['para'] < 1 && $rw['para'] = 1;
                         break;
                     case 'page':
                         $rw['page'] = $ru['1'];
                         $rw['para'] < 2 && $rw['para'] = 2;
                         break;
                     case 'type':
                         $rw['type'] = $ru['1'];
                         $rw['para'] < 4 && $rw['para'] = 4;
                         break;
                     default:
                         $rw['para'] = 8;
                         $urlfail = 1;
                         break;
                         }
                     }
                 }
                 switch($rw['para']){
                 case '1':
                       $url = "forum-" . $rw['fid'] ."-" ."1" . "-" ."1". ".html";
                     break;
                 case '2':
                     $url = "forum-" . $rw['fid'] .  "-" . $rw['page'] ."-" ."1".  ".html";
                     break;
                 case '4':
                     $url = "forum-" . $rw['fid'] . "-" . $rw['page'] . "-" . $rw['type'] . ".html" ;
                     break;
                     }
         }elseif(strpos($url, 'read.php?') !== false){
             unset($rw);
             $rarr = explode('&', substr(str_replace($add, '', $url), 9));
             foreach($rarr as $key => $value){
                 $ru = explode('=', $value, 2);
                 if($ru['1']){
                     switch($ru['0']){
                     case 'tid':
                         $rw['tid'] = $ru['1'];
                         $rw['type'] < 1 && $rw['type'] = 1;
                         break;
                     case 'page':
                         $rw['page'] = $ru['1'];
                         $rw['type'] < 2 && $rw['type'] = 2;
                         break;
                     case 'fpage':
                         $rw['fpage'] = $ru['1'];
                         $rw['type'] < 3 && $rw['type'] = 3;
                         break;
                     default:
                         $rw['type'] = 4;
                         $urlfail = 1;
                         break;
                         }
                     }
                 }
             switch($rw['type']){
             case '1':
                  $url = "thread-" . $rw['tid'] . "-" ."1" . "-" ."1". ".html";
                 break;
             case '2':
                 $url = "thread-" .  $rw['tid'] . "-" . $rw['page'] ."-" ."1".  ".html";
                 break;
             case '3':
                 $url = "thread-" .  $rw['tid'] . "-" . $rw['page'] . "-" . $rw['fpage'] . ".html";
                 break;
                 }
             }
         if($urlfail){
             $url = str_replace(
                array('.php?', '=', '&', $add),
                 array($db_dir, '-', '-', ''),
                 $url
                ) . $db_ext . $add;
             }
         }elseif(strpos($url, 'hack.php?') !== false){
             unset($rw);
             $rarr = explode('&', substr(str_replace($add, '', $url), 9));
             foreach($rarr as $key => $value){
                 $ru = explode('=', $value, 2);
                 if($ru['1']){
                     switch($ru['0']){
                     case 'H_name':
                         $rw['H_name_value'] = $ru['1'];
                         if(in_array($rw['H_name_value'],array('fenlei','mm'))){
                             $rw['type'] = 1;
                         }
                         break;
                     }
                 }
                 switch($rw['type']){
                 case '1':
                     $url = $rw['H_name_value'] . "/";
                     break;
             //case '2':
             //    $url = $rw['tid'] . "_" . $rw['page'] . ".html";
             //    break;
             //case '3':
             //    $url = $rw['tid'] . "_" . $rw['page'] . "_" . $rw['fpage'] . ".html";
             //    break;
                 }
             }
         }
     return "$url";
}
演示:http://www.discuz.net/thread-3456814-1-1.html
 您阅读这篇文章共花了: 
 本文无需标签!
二维码加载中...
本文作者:haofeng      文章标题: phpwind8.7仿discuz伪静态规则实现方法
本文地址:https://www.fenghaofeng.com/post-145.html
版权声明:若无注明,本文皆为“独家回忆-好风网”原创,转载请保留文章出处。
返回顶部    首页   
版权所有:独家回忆-好风网    站长: haofeng   核心程序:emlog   浙ICP备15004455号-3    

浙公网安备 33050202000124号