0
篇帖子
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>
本博客内所有原创和翻译的文章的版权归本人所有,允许第三方转载,但转载时请务必保留作者名,并注明出处链接,否则本人将保留追究其法律责任的权利。
「人生在世,留句话给我吧」