文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

PHPwind 伪静态简化URL长度为1.html,f2等的方法介绍

2022-06-12 01:52

关注

1。根目录下.htaccess(规则适用iis,其他nginx、apache还要稍做修改)

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 [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]

2、在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";

}

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯