php framework workerman pseudo-static transformation detail

First, find the \ vendor \ workerman \ workerman \ WebServer.php line 176, read as follows, increasing the judgment of the html file extension does not exist:

if (in_array($workerman_file_extension,['php','html']) && !is_file($workerman_file)) {
    $workerman_file = "{$workerman_root_dir}/index.php";
    $workerman_file_extension = 'php';
    if (!is_file($workerman_file)) {
        $workerman_file= "{$workerman_root_dir}/index.html";
        $workerman_file_extension = 'html';
    }
}

After this, simply go to the html file with the extension, and the file does not exist, it will automatically redirect to index.php, and then judge in index.php on line

Two, index.php transformation, before the output page, add the following judgment:

1 //重定向判断
2 $uri=$_SERVER['REQUEST_URI'];
3 $ext=strtolower(substr($uri,-4,4));
4 if(is_cli()&&$ext=='html'){
5   $_GET['_']=substr($uri,1,strlen($uri)-5);
6 }

I visited the address is http://c.com/Users_login.html, namely access index.php? _ = Users_login

Third, according to the $ _GET [ '_'], underlined segmentation, a method which load classes and determines, on the line. such as:

1 $_GET['_']=isset($_GET['_'])?$_GET['_']:strcode('Index_index');
2 $strs=strcode($_GET['_'],'DECODE');
3   if(!$strs)xdie('param error.');
4     $d=preg_split('/[\.\_]/',$strs);
5       if(count($d)<2)xdie('error:param');
6         $class=$d[0].'Action';
7         $action=$d[1];

And then load the class and run on the line

Guess you like

Origin www.cnblogs.com/mo3408/p/12148264.html