2014-07-23 33 views
0

我想檢索字符串使用以下URL方案的參數: www.myapp.com/[String]笨 - 在URL檢索參數,而控制器名稱

有沒有什麼辦法可以做到這一點? *根據我的研究,Codeigniter不接受字符串參數,除非我在URL中包含控制器的名稱:www.myapp.com/[Controller Name]/[String] 但是這並不能解決我的問題: (

+0

你有什麼問題。 ? – Adeel

回答

2

你說得對,CI要求控制器名稱爲URI,但您可以使用default_controller

config/routes.php添加路由規則$routes['(:any)'] = '歡迎/索引'。, remove index.php from Your URL (there're many tutorials and how-to for this), and at last use URI class at Your指數()method of welcome`控制器:

function index(){ 
    var_dump($this->uri->uri_string()); 
} 
+0

按照你的指示,我輸入「myapp.com/[String]」後,我重定向到404。我認爲它仍然在尋找控制器(而不是參數)? – m0dE

+0

沒關係。它在更改$ routes後運作[to $ route [!!] – m0dE

相關問題