http://xxx.com/ 中文首页
http://xxx.com/en 英文首页
http://xxx.com/de 德文首页
对应的控制器方法是 app\controller\IndexController::index
http://xxx.com/product 中文产品页
http://xxx.com/en/product 英文产品页
http://xxx.com/de/product 德文产品页
对应的控制器方法是 app\controller\ProductController::index
http://xxx.com/product/123 中文产品页
http://xxx.com/en/product/123 英文产品页
http://xxx.com/de/product/123 德文产品页
对应的控制器方法是 app\controller\ProductController::detail
...
请问路由规则应该怎么写?
实际上采用
session与kv配置,就很好解决甚至更复杂的也可以!不同的路由规则使用同一个方法处理,追加参数就可以:
方法注入参数:
需要最新版本的
webman-framework,版本老可能不支持其实也没那么复杂,看手册就是知道,可以用[xxx]代表缺省的
Route::get('/[lang]', IndexController::class . '@index')
Route::get('[/lang]/product ', ProductController::class . '@index')
这样应该可以的