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.
Just for a laugh, see if
/index.php/hello
works.If so, then most likely it's a
.htaccess
problem.Go to
find try_file and replace as below:
try_files $uri $uri/ /index.php?$query_string;
I tried all these with no success then i found another post and changed my .htaccess to this:
I had the same problem and the solution was enable the rewrite mod on Apache2
In a terminal use the following commands:
And magic!
There was a little flaw in a previous answer. This might help out.
Hope it does.
I had this problem (on Windows with manually installed Apache 2.2), and the cause was a missing
AllowOverride
in my VirtualHost as the root directory in httpd.conf was defaulted to None.FileInfo Options=MultiViews
is the minimal set you need for Laravel's .htaccesse.g.
Or use
AllowOverride All
if this doesn't work and you don't care for security.