PHPwind怎么改写超级伪静态变量

来源:爱站网时间:2022-01-08编辑:网友分享
爱站技术频道小编今天给大家讲解下有关于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']                 break;
                case 'page':
                    $URL_type['page'] = $URL_array['1'];
                    $URL_type['type']                 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']                             break;
                        case 'page':
                            $URL_type['page'] = $URL_array['1'];
                            $URL_type['type']                             break;
                        case 'fpage':
                            $URL_type['fpage'] = $URL_array['1'];
                            $URL_type['type']                             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

每个程序都有属于它们自己的独特风格,掌握好尺度就能让整个操作系统变得顺畅。看完这篇文章后是不是感触很深呢?关注我们,你会获得更多技术资讯。

上一篇:phpcms v9忘记管理员后台密码怎么办

下一篇:phpwind iis下伪静态规则是怎样的

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载