一、路由注册
动态路由
语法:Route::rule('路由规则','路由地址','请求方式',[路由参数],[变量规则]);
think\Route::rule('hello/:name','index/index/hello','GET',['ext'=>'html'],['name'=>'\w{1,10}']);
原请求地址:http://你的域名/index/index/hello/name/zhangsan
路由地址:http://你的域名/hello/zhangsan.html
配置数组(配置文件):
语法:
return [
'路由规则'=>['路由地址',[请求方式,路由参数],[变量规则]],
]
return [
'demo/:age'=>['index/index/demo',['method'=>'get','ext'=>'html'],['age'=>'\d+']],
]
原请求地址:http://你的域名/index/index/demo/age/18
路由地址:http://你的域名/age/18.html