zoukankan      html  css  js  c++  java
  • PHPwind高级伪静态规则及方法

    phpwind iis下伪静态规则
    [ISAPI_Rewrite]
    RewriteRule ^(.*)/(.*)-htm-(.*)-(.*).html$ $1/$2.php?$3=$4
    RewriteRule ^(.*)/read-htm-tid-(.*).html$ $1/read.php?tid=$2
    RewriteRule ^(.*)/thread-htm-fid-(.*).html$ $1/thread.php?fid=2
    RewriteRule ^(.*)/simple/([a-z0-9\_]+.html)$ $1/simple/index.php?$2
    phpwind apache下伪静态规则
    RewriteEngine On
    RewriteRule ^(.*)/thread-htm-tid-(d+)-(.*).html  $1/thread.php?fid=$2
    RewriteRule ^(.*)/read-htm-tid-(d+)-(.*).html  $1/read.php?tid=$2
    RewriteRule ^(.*)/commtopics-(d+)-(.*)$ $1/thread.php?fid=$2&page=$3
    RewriteRule ^(.*)/commtopics-(.*)$      $1/thread.php?fid=$2&page=$3
    RewriteRule ^(.*)/article-(d+)-(d+)-(.*).html$  $1/read.php?tid=$2&page=$3&fpage=$4
    RewriteRule ^(.*)/article-(d+)-(.*).html$       $1/read.php?tid=$2&page=$3
    RewriteRule ^(.*)/article-(.*).html$         $1/read.php?tid=$2
    RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
    RewriteRule ^(.*)/simple/([a-z0-9\_]+.html)$ $1/simple/index.php?$2
    phpwind nginx下伪静态规则
    location / {
    rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
    rewrite ^(.*)/simple/([a-z0-9\_]+.html)$ $1/simple/index.php?$2 last;
    }

    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 或者其他
    <IfModule mod_rewrite.c>
    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
    </IfModule>

  • 相关阅读:
    C语言中const关键字的用法
    LDO和DC-DC的概念,区别及优缺点
    Ubuntu下几个命令行方式使用的图片浏览工具
    I2C和I2S的区别和使用方法
    scikit-image 图像处理库介绍
    USB协议介绍
    Ubuntu 16.04 python和OpenCV安装
    一种基于python的人脸识别开源系统
    numpy 介绍
    python enumerate用法总结
  • 原文地址:https://www.cnblogs.com/2881064178dinfeng/p/6233626.html
Copyright © 2011-2022 走看看