return[
'woman'=> 'Home/Goodsl/goodsList/id/1',
'man/'=>'Home/Goodsl/goodsList/id/2',
'yanshi' =>'Home/Goodsl/goodsList/id/3',
];
在thinkPHP5中如何让不同参数id对应不同的静态路由,一个id值对应一个路由的url。比如
/woman/ 对应的原路由地址为/Home/Goodsl/goodsList/id/1,
/man/ 对应的原路由地址为/Home/Goodsl/goodsList/id/2,
/yanshi/ 对应的原路由地址为/Home/Goodsl/goodsList/id/3,
也就是说
woman对应的id=1,
man对应的id=2,
yanshi对应的id=3,
……
这样的方式。
这个路由如何写呢。
通过官方文档来看,是用Route:
Route::rule(['new','new/:id'],'index/News/read');
应该是:
<?php
# 引用路由
use think\Route;
# /woman/ 对应的原路由地址为/Home/Goodsl/goodsList/id/1
Route::rule('/woman','/Home/Goodsl/goodsList/id/1');
# /man/ 对应的原路由地址为/Home/Goodsl/goodsList/id/2
Route::rule('/man','/Home/Goodsl/goodsList/id/1');
# /yanshi/ 对应的原路由地址为/Home/Goodsl/goodsList/id/3
Route::rule('/yanshi','/Home/Goodsl/goodsList/id/3');
前端测试路由URL并不会变化,说明路由还是没有成功。