Laravel 4 All Routes Except Home Result in 404 Error

Amit Erandole picture Amit Erandole · Nov 22, 2012 · Viewed 61.1k times · Source

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');
});

This is not:

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

What I'm trying to hit is TasksController at /tasks:

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

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>

I am using localhost on a Mac.

Answer

GaryJ picture GaryJ · Nov 22, 2012

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

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