我是PHP/Laravel的新手,这可能很愚蠢,但我无法得到这个工作。我在我的routes.php
文件中定义这两条路线:Laravel 4路线打击公共文件夹,而不是观看文件夹
Route::get('about', function()
{
return 'this is about';
});
Route::get('/', array('as'=>'home', function()
{
return View::make('hello');
}));
如果我访问喜欢我的应用程序:http://testapp.dev:88它正确地呈现视图。不过,我得到一个404,如果我访问我的应用程序一样http://testapp.dev:88/home或http://testapp.dev:88/about
我检查了Apache日志,发现这些错误:
[错误] [客户端127.0.0.1]文件不存在: C:/ tmp目录/ Git_Repository /网站/ testapp /公/约
[错误] [客户端127.0.0.1]文件不存在: C:/ tmp目录/ Git_Repository /网站/ testapp /公/家
任何想法为什么会发生这种情况?
注:我使用WAMP,并具有以下的Apache 2.2.22配置
<Directory "C:/tmp/Git_Repository/website/">
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
<VirtualHost *:88>
DocumentRoot "C:\tmp\Git_Repository\website\testapp\public"
ServerName testapp.dev
</VirtualHost>
感谢您的帮助。
你的'public'目录中是否有Laravel'.htaccess'文件? – mkorcha
看起来像'/ public'目录中的'.htaccess'文件丢失或重写规则不起作用。确保你有'.htaccess'文件:https://github.com/laravel/laravel/blob/master/public/.htaccess和'mod_rewrite'安装/启用。顺便说一句:路由的名称(如'['as'=>'home'...]'不会使'/ home'成为一个可访问的URI,它只是为了更好地引用您的应用程序,例如'URL :: route('home')'。所以你可以引用这个名字,不管实际的路由是什么样子。 – Quasdunk
你还没有定义home路由,如果你不能访问关于被定义的路由,那么必须我的猜测是默认访问http:// localhost/public /约 –