在第一.htaccess
,我送url
到public/index.php
:清潔網址
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ public/index.php [NC,L]
而且我public/index.php
:
<?php
// define root path of the site
if(!defined('ROOT_PATH')){
define('ROOT_PATH','../');
}
require_once ROOT_PATH.'function/my_autoloader.php';
use application\controllers as controllers;
$uri=strtolower($_SERVER['REQUEST_URI']);
$actionName='';
$uriData=array();
$uriData=preg_split('/[\/\\\]/',$uri);
$actionName = (!empty($uriData[3])) ? preg_split('/[?].*/', $uriData[3]): '' ;
$actionName =$actionName[0];
$controllerName = (!empty($uriData[2])) ? $uriData[2] : '' ;
switch ($controllerName) {
case 'manage':
$controller = new Controllers\manageController($controllerName,$actionName);
break;
default:
die('ERROR WE DON\'T HAVE THIS ACTION!');
exit;
break;
}
// function dispatch send url to controller layer
$controller->dispatch();
?>
我有這樣的目錄:
- 應用
-
個
- 控制器
- 車型
- 視圖
- 公共
css
java script
- 的index.php
.htaccess
我想幹淨URL
例如localhost/lib/manage/id/1
而不是localhost/lib/manage?id=1
,我該怎麼辦?
在這個URL'localhost/lib/manage/id/1'中哪些文件夾名稱字符串是動態的,哪些是固定的? –