我刚开始学习Laravel框架,但是在路由方面遇到了问题。
唯一能工作的路由是Laravel默认提供的主页路由。
我在Windows上使用WAMP,它使用的是PHP 5.4.3和Apache 2.2.22,我同样也启用了mod_rewrite,并已将应用程序的config文件中的“index.php”删除,以留下一个空字符串。
我创建了一个名为User的新控制器:
class User_Controller extends Base_Controller {
public $restful = true;
public function get_index()
{
return View::make('user.index');
}
}
我已经在application/views/user/中创建了一个名为index.php的视图文件,并添加了一些基本的HTML代码,在routes.php文件中添加了以下内容:
Route::get('/', function () {
return View::make('home.index');
});
Route::get('user', function () {
return View::make('user.index');
});
当我在浏览器中访问根路由 (http://localhost/mysite/public
) 时,第一条路由能够正常工作,但是当我尝试访问第二条路由 http://localhost/mysite/public/user
时,会收到404 Not Found错误。为什么会发生这种情况呢?