[英]Need help using routes in CodeIgniter
我對codeiIgniter中的路由工作方式有些困惑。 我設置了以下路線
$route['myfirstest'] = 'Blogs';
然后,我在application / controllers目錄下設置了一個名為blogs.php的php文件。
當我運行以下網址時
/code_igniter/index.php/myfirstest/hello/hello
我收到404訊息
但是,當我運行以下URL時
/code_igniter/index.php/blogs/hello/hello
它可以找到
任何人都可以幫我解決這個問題。也許我沒有正確獲得整個路線。
我想這對你有用
$route['myfirstest'] = 'Blogs';
$route['myfirstest/(:any)'] = "Blogs/$1"
這也將為您工作。但我認為這不是您的真正目的。
$route['myfirstest/hello/hello'] = "Blogs/hello/hello";
如果您想在hello函數中輸入任何值,可以這樣編寫
$route['myfirstest/hello/(:any)'] = "Blogs/hello/$1";
請記住,對於第二和第三解決方案,您還需要編寫
$route['myfirstest'] = 'Blogs';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.