Codeigniter - 在URL中检索没有控制器名称的参数

时间:2014-07-23 23:41:53

标签: codeigniter url uri codeigniter-url

我尝试使用以下网址方案检索字符串作为参数: www.myapp.com/[String]

我有什么方法可以做到这一点吗?

*根据我的研究,Codeigniter不接受字符串参数,除非我在URL中包含Controller的名称:www.myapp.com/ [Controller Name] / [String] 但这并没有解决我的问题:(

1 个答案:

答案 0 :(得分:2)

你是对的,CI需要URI的控制器名称,但你可以使用default_controller。

config/routes.php添加路由规则$routes['(:any)'] =' welcome / index'; , remove index.php from Your URL (there're many tutorials and how-to for this), and at last use uri class at Your index()method of welcome`控制器:

function index(){
    var_dump($this->uri->uri_string());
}
相关问题