Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 All Routes Except Home Result in 404 Error

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.

like image 498
Amit Erandole Avatar asked Nov 22 '12 14:11

Amit Erandole


People also ask

How do I fix error 404 in Laravel?

It should be enough to just run php artisan vendor:publish --tag=laravel-errors and then edit the newly created resources/views/errors/404.

What does 404 not found mean in Laravel?

Error 404 is a client-side issue indicating the requested URL can't be found on the server. It may occur because of several reasons, such as the domain is not pointed correctly, a broken . htaccess file, or misconfigured file permissions.

Where is the 404 page in Laravel?

In your Laravel project folder, create a folder called “errors” in your /resources/views/ folder. Create a file called 404. blade. php in this /resources/views/errors/ folder.

How do I link my 404 page in Laravel?

Create Custom 404 Error Page You need to create blade views for error pages, move to this path resources/views/ inside here create errors folder and within the directory create 404. blade. php file. It will redirect you to the 404 page if you don't find the associated URL.


2 Answers

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

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

like image 77
GaryJ Avatar answered Oct 02 '22 10:10

GaryJ


Had the same problem running Laravel 4 on WAMP (Windows 8).
The solution that worked for me was:

  1. Open apache httpd.conf and find this line :

    #LoadModule rewrite_module modules/mod_rewrite.so 
  2. Uncomment this line (remove the #)
  3. Save httpd.conf
  4. Restart WAMP

It should be working!

like image 39
Rutger Avatar answered Oct 02 '22 10:10

Rutger