MVC框架自定义隐藏index.php入口文件伪静态

PHP:

public function initPath(){
        $path = $_SERVER['PATH_INFO'];
        $lastFix = strrchr($path,'.');
        $path = str_replace($lastFix,'',$path);
        $path = substr($path,1);
        $array = explode('/',$path);
        $lenght = count($array);
        if ($lenght == 1){
            $_GET['m'] = $array[0];
        }elseif ($lenght == 2){
            $_GET['m'] = $array[0];
            $_GET['c'] = $array[1];
        }elseif ($lenght == 3){
            $_GET['m'] = $array[0];
            $_GET['c'] = $array[1];
            $_GET['a'] = $array[2];
        }else{
            $_GET['m'] = $array[0];
            $_GET['c'] = $array[1];
            $_GET['a'] = $array[2];
            for ($i=3;$i<$lenght;$i+=2){
                $_GET[$array[$i]] = $array[$i+1];
            }
        }
    }

Nginx:

if (!-d $request_filename){
	set $rule_0 1$rule_0;
}
if (!-f $request_filename){
	set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
	rewrite /(.*) /index.php/$1;
}

Apache:

<IFModule rewrite_module>
	RewriteEngine on
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f

	RewriteRule (.*) index.php/$1

</IFModule>
Comments: 0

「人生在世,留句话给我吧」

提交评论