代码点火器url段

时间:2015-09-04 07:41:10

标签: codeigniter uri codeigniter-url

目前我的网站网址是 https://www.thefoolsbookie.com/main/inside?id=8 但我希望这就像这样 https://www.thefoolsbookie.com/nfl 我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

编辑application / config / routes.php文件并为其添加新路由

$route['nfl'] = 'main/inside';

应该如此简单:)

有关更多示例,请参阅https://ellislab.com/codeigniter/user-guide/general/routing.html

修改

我已经和CI一起工作了很长时间,而且我从未见过它以这种方式在路径文件中使用GET参数。我不确定是否有可能。

你可以像$route['nfl'] = 'main/inside/8';

那样

然后在主控制器中你的内部方法看起来像:

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
}