2015-01-11 76 views
0

我對codeiIgniter中的路由工作方式有點困惑。我已經建立了這個以下航線在CodeIgniter中使用路由需要幫助

$route['myfirstest'] = 'Blogs'; 

然後我成立了一個名爲blogs.php一個PHP文件的應用程序/控制器目錄下

當我運行下面的網址

/code_igniter/index.php/myfirstest/hello/hello 

我得到404消息

但是,當我運行以下URL時

/code_igniter/index.php/blogs/hello/hello 

它可以找到

誰能請幫助我這個out..Maybe我沒有得到正確的整條路線的事..

+0

您還需要添加此$ route ['myfirstest /(:any)'] =「博客/ $ 1」; –

回答

0

我認爲這會爲你工作

$route['myfirstest'] = 'Blogs'; 
$route['myfirstest/(:any)'] = "Blogs/$1" 

這也適用於你。但我不認爲這是你的真正目的。

$route['myfirstest/hello/hello'] = "Blogs/hello/hello"; 

如果你想招呼函數中的任何值,你可以寫這樣

$route['myfirstest/hello/(:any)'] = "Blogs/hello/$1"; 

記住第二和第三的解決方案,你還需要編寫

$route['myfirstest'] = 'Blogs';