一:配置:
文件位置 public/index.php
<?php
// [ 應用入口文件 ]
namespace think;
require __DIR__ . '/../vendor/autoload.php';
// 當前應用目錄
define('APP_PATH',dirname(__DIR__));
// WEB入口文件位置
define('PUBLIC_PATH','/public');
// 上傳文件夾
define('UPLOAD','/uploads');
// 模板部署
define('TEMPLATE_PATH', 'template');
// 執行HTTP應用並響應
$http = (new App())->http;
$response = $http->run();
$response->send();
$http->end($response);
注意:一些常用的常量可以在index.php配置;也可以在中間件里面加載
好處:方便常量調用,比如定義模板文件(后面會介紹到)
二:隱藏:
【nginx】
在Nginx低版本中,是不支持PATHINFO的,但是可以通過在Nginx.conf中配置轉發規則實現:
location / { // …..省略部分代碼
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
}
【apache】
【IIs】
************************************************
Thinkphp高級交QQ流群:101766150
作者:狂奔的蝸牛
轉載請注明出處
************************************************