Laravel 4除首页外的所有路由都导致404错误 [英] Laravel 4 All Routes Except Home Result in 404 Error

查看:36
本文介绍了Laravel 4除首页外的所有路由都导致404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Composer 安装了 Laravel 4,还设置了一个虚拟主机.目前,只有根路由有效:

I installed Laravel 4 using Composer and also set up a virtual host. Currently, only the root route is working:

<?php

Route::get('/', function()
{
    return View::make('hello');
});

这不是:

Route::get('/hello', function()
{
    return View::make('hello');
});

我要打的是 TasksController/tasks:

Route::resource('tasks', 'TasksController');

这也给了我 404 错误.我可能做错了什么?我的项目根目录中有一个默认的 .htaccess 文件:

This is giving me 404 error as well. What could I be doing wrong? I have a default .htaccess file at the root of my project:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

我在 Mac 上使用 localhost.

I am using localhost on a Mac.

推荐答案

开个玩笑,看看 /index.php/hello 是否有效.

Just for a laugh, see if /index.php/hello works.

如果是这样,那么很可能是 .htaccess 问题.

If so, then most likely it's a .htaccess problem.

这篇关于Laravel 4除首页外的所有路由都导致404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆