我目前正在與Codeigniter一起開展一個項目。默認情況下,在CodeIgniter上重定向到控制器+操作的路由?
我稱之爲一個控制器貓
class Cat extends CI_Controller {
function __construct(){
parent::__construct();
}
function index($action){
// code here
}
}
和路徑(在routes.php文件)
$route['cats/:any'] = 'cat/index/$1';
這工作,如果我使用這個網址,例如:http://www.mywebsite.com/cats/display
然而,如果用戶將URL更改爲http://www.mywebsite.com/cats/,則不再有效。 Codeigniter寫道:404未找到頁面 - 找不到您請求的頁面。
所以我的目標是在默認情況下,以他重定向到http://www.mywebsite.com/cats/display如果他是貓/頁
我需要做的另一條路線呢? 我試過
$route['cats'] = 'cat/display';
...但沒有成功。感謝您的幫助。
感謝您的答覆! – Dacobah