2013-08-07 55 views
1

如果我有這樣一種形式:做使用URI段中的CodeIgniter GET請求

<form method="GET"> 
    <input type="text" name="search" /> 
</form> 

,如果我提交它,它會產生這樣的URL:
http://exmaple.com/search/results?search=text1+text2

現在,這並不使用我的代碼。我如何使其使用URI段,所以生成的URL看起來是這樣的:http://exmaple.com/search/results/search/text1+text2

更多的澄清 換句話說,我想的是,當我用一個簡單的HTML形式的GET請求的URL它產生看起來像CodeIgniter的URL使用笨路由即
example.com/class/function/param1/param2
而不是
example.com/class/function?param1&param2

+0

你嘗試過在使用CodeIgniter的路線? 'http:// ellislab.com/codeigniter/user-guide/general/routing.html' –

+0

以及我剛剛嘗試添加此路線:'$ route ['search/results?search =(:any)'] =「search/results/search/$ 1「;'但它不起作用 – Krimson

+0

試試這個'$ route ['search/results/search /(:any)'] =」search/results?search = $ 1「'你切換了它們。 –

回答

0

可以實現http://exmaple.com/search/results/search/text1+text2

通過把這個在你的路線

$route['search/results/search/(:any)'] = "search/results?search=$1" 
+0

我想你錯過了解我的問題。我想要的是,當我使用簡單的html表單獲取請求時,它生成的url看起來像codeigniter的URL,即'example.com/class/function/param1/param2',而不是'example.com/class/function ?參數1和參數2 – Krimson

1
in your codeigniter config file $config['enable_query_strings'] is set to false, so the url looks like http://example.com/search/results/search/text1+text2 

if you want url like http://example.com/search/resutls?search=text1+text2 then set $config['enable_query_strings'] to true;