PHPWind 8.5和8.7版的伪静态.htaccess规则

  • 时间:
  • 浏览:0
  • 来源:5分11选5娱乐平台-5分11选5下注平台_5分11选5注册平台
作者:匿名 hihi 来源:ChinaZ源码报导 浏览: 2011-9-20 11:52:24 字号:大 中 小

[摘要]PHPWind是另另俩个基于PHP和MySQL的论坛系统线程,是国内最受欢迎的通用型论坛系统线程之一。本文介绍通过修改apache的.htaccess实现伪静态的效果。

  日前PHPWind发布了8.7的新版本,站长们升级后或者 伪静态规则只能使用。本文介绍修改Apache的.htaccess来实现伪静态的效果,效果如下:

http://www.phpwind.net/fxx        板块

http://www.phpwind.net/60 0.html 帖子

  修改根目录下.htaccess规则,代码如下:

RewriteEngine on

RewriteRule f(\d+)_(.*)_(.*)$ /thread.php?fid=$1&page=$2&type=$3 [L]

RewriteRule f(\d+)_(.*)$ /thread.php?fid=$1&page=$2 [L]

RewriteRule f(\d+)$ /thread.php?fid=$1&page=$2 [L]

RewriteRule (\d+)_(.*)_(.*)_(.*).html$ /read.php?tid=$1&page=$2&fpage=$3&uid=$4 [L]

RewriteRule (\d+)_(.*)_(.*).html$ /read.php?tid=$1&page=$2&fpage=$3 [L]

RewriteRule (\d+)_(.*).html$ /read.php?tid=$1&page=$2 [L]

RewriteRule (\d+).html /read.php?tid=$1 [L]

RewriteRule ^(.*)-htm-(.*)$ $1.php?$2 [L]

RewriteRule /simple/([a-z0-9\_]+)\.html$ /simple/index\.php\?$1 [L]

  打开文件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 = "f" . $rw['fid'] ;

                     break;

                 case '2':

                     $url = "f" . $rw['fid'] . "_" . $rw['page'] ;

                     break;

                 case '4':

                     $url = "f" . $rw['fid'] . "_" . $rw['page'] . "_" . $rw['type'] ;

                     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 = $rw['tid'] . ".html";

                 break;

             case '2':

                 $url = $rw['tid'] . "_" . $rw['page'] . ".html";

                 break;

             case '3':

                 $url = $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";

}

后台把伪静态功能开启即可。

sssss
Tags: phpwind   phpwind8.7   phpwind.htaccess   phpwind伪静态  
责任编辑:190