在 Codeigniter 的文档中https://www.codeigniter.com/user_guide/tutorial/static_pages.html
我无法理解$1表达的意思 $route['(:any)'] = 'pages/view/$1';
在 Codeigniter 的文档中https://www.codeigniter.com/user_guide/tutorial/static_pages.html
我无法理解$1表达的意思 $route['(:any)'] = 'pages/view/$1';
$route['(:any)'] = 'pages/view/$1';
意味着您在 url 上键入的任何内容都将转到pages/view/$1这里$1是您要传递给控制器/方法示例的参数
$route['login/(:any)'] = 'home/bacon/$1';
在这个例子中,你告诉 CI 任何login与任何参数类似的东西都login/john将继续你home/bacon/john (:any)将匹配所有字符串和整数,如果你使用(:num)它只会匹配整数参数,比如
$route['login/(':num')'] = 'home/bacon/$1'
在此配置中,您指定如果 urllogin在它之后有一个整数 like ,如果您不知道要传递多少个参数
login/1234,您希望它重定向到您可以尝试
更多可以在
https 上阅读: //www.codeigniter.com/user_guide/general/routing.htmlhome/bacon/1234$route['login/(:any).*'] = 'home/bacon/$1'
$1 would be whatever matched by (:any) group - which is, really, anything. Whatever you add will get passed as the parameter for view method in pages controller.
More here on routing with codeigniter.