[英]Code igniter url segment
目前,我的网站网址是https://www.thefoolsbookie.com/main/inside?id=8,但我希望它像这样https://www.thefoolsbookie.com/nfl我该怎么做?
Edit the application/config/routes.php file and add a new route for it 编辑application / config / routes.php文件并为其添加新的路由
$route['nfl'] = 'main/inside';
It should be as simple as that :) 它应该像那样简单:)
See https://ellislab.com/codeigniter/user-guide/general/routing.html for more examples. 有关更多示例,请参见https://ellislab.com/codeigniter/user-guide/general/routing.html 。
I've worked with CI for a long time and I've never seen it use GET params in the routes file in that way. 我使用CI已有很长时间了,但从未见过它以这种方式在路由文件中使用GET参数。 I'm not sure it is possible.
我不确定是否有可能。
You could have it like $route['nfl'] = 'main/inside/8';
您可以像
$route['nfl'] = 'main/inside/8';
then in the main controller your inside method would look like: 然后在主控制器中,您的内部方法将如下所示:
public function inside($id)
{
//$id would contain the ID of 8 when you go to
//https://www.thefoolsbookie.com/main/inside/8
//or https://www.thefoolsbookie.com/nfl
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.