• 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>

  • 相关阅读:
    大网管 www.bigit.com
    WinAPI: midiOutUnprepareHeader 清除由 midiOutPrepareHeader 完成的准备
    WinAPI: midiInGetNumDevs 获取 MIDI 输入设备的数目
    WinAPI: midiInUnprepareHeader 清除由 midiInPrepareHeader 完成的准备
    WinAPI: midiInPrepareHeader 为 MIDI 输入准备一个缓冲区
    转贴一组 Delphi 官方网站介绍 IDE 功能的动画
    WinAPI: midiOutPrepareHeader 为 MIDI输出准备一个缓冲区
    WinAPI: midiOutGetNumDevs 获取 MIDI 输出设备的数目
    WinAPI: midiInGetID 获取输入设备 ID
    动画演示 Delphi 2007 IDE 功能[4] 自定义界面
  • 原文地址:https://www.cnblogs.com/2881064178dinfeng/p/6233626.html
Copyright © 2020-2023  润新知