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.
Had the same problem running Laravel 4 on WAMP (Windows 8).
The solution that worked for me was:
Open apache httpd.conf and find this line :
#
)httpd.conf
It should be working!
Even after enabling mod_rewrite, you may face this problem if you are aliasing your laravel/public folder.
Adding
to .htaccess does the trick.
Since Laravel 4 is autoloading files from a map in a static file, you need to update that file when you add a new controller. Run this command to rebuild the static file:
This comment may be a little late but it may help. I had the same problem when routing to another view like this:
But didn't work so I tried everything i found in all the related posts but wasn't enough to solve my problem so i found this lines on the httpd.conf:
So i changed "denied" to "granted" and also commented this line on my .htaccess:
And worked!! I think this lines make Apache not consider the .htaccess file of your project so turning it to granted made the difference. Hope this can help someone with the same problem.
Working on Apache Server 2 @ Manjaro Linux (based on Archlinux)
This update worked for me. In the .htaccess file simply add the following after the Rewriterules are turned on.
Worked like charm
You don't need a / when defining anything other than home:
Should work.