Laravel quick start guide route not working

Solution 1:

Seems like your Laravel app is accesible via an Apache HTTP alias, because your URL looks like: http://localhost/laravel/. If this is the case and assuming that http://localhost/laravel is pointing to your public directory, then follow these steps:

  1. Try to navigate to your expected route prepend it with /index.php/, in your case: http://localhost/laravel/index.php/users. If it works (no 404) then you problem is with the Rewrite Module configuration of Apache HTTP, you should follow the next steps.
  2. Edit the file public/.htaccess.
  3. Under the line RewriteEngine On add RewriteBase /laravel/.
  4. Try to navigate to an existing route.

Basically, if you app resides in a alias or virtual directory (say http://localhost/alias) you should add an entry in your rewrite rule to rewrite the base directory with alias.

Solution 2:

The problem is well explained by Rubens above, A simpler solution is to use the supplied built-in PHP Server by issuing this command

php artisan serve --port=8080

Note that I am using port 8080 here, you can omit it.Now you can browse the site by going to

localhost/users

and it should work!

Solution 3:

Apache isn't probably reading the public/.htaccess file due to the directive AllowOverride being set to None. Try to set it to All.

Laravel 4 simple route not working using mod_rewrite, and .htaccess

Solution 4:

I had the same problem and spent hours to solve it. I have several apps under the same domain, but in different segments. So Laravel's url is http://myhostname/mysubdir/

My controllers were only working as http://myhostname/mysubdir/index.php/mycontroller

On /var/www/.../public/.htaccess I put RewriteBase /mysubdir and worked!!!

Solution 5:

I know this question is 4 years old but still it have its significance.Rubens Mariuzzo was answered it correctly but I want to add some points on it. You said

"There are massive holes in the documentation so it took a lot of effort and googling to fill the gaps in order to get Laravel set-up"

For beginners it is difficult to find correct way of configuring Laravel. Once it is mastered it is fun developing Laravel :) . There are certain correct way of doing this.

  1. Download Laravel
  2. Configure DB
  3. Map DB in .env
  4. Make auth: php artisan make:auth
  5. Create model and migration together: php artisan make:model Todo -m
  6. Migrate: php artisan migrate
  7. Create controller and routes together: php artisan make:controller TodoController --resource
  8. Create view for each action
  9. Code the controller

Detailed description is given in this blog http://masterlaravel.blogspot.in/2017/08/laravelquick-start-composer-create.html