1

I have installed fresh copy of laravel 5.3.

I have the following code in my route/web.php.

Route::get('/', function () {
    return view('welcome');
});

Route::get('welcome', function () {
    return view('welcome');
});

when i hit localhost/project/public in the browser i can see laravel welcome page.

But when i hit localhost/project/public/welcome then 404 Not Found comes up where i should get the same laravel welcome page.

Am i forgetting something ?

Gammer
  • 5,453
  • 20
  • 78
  • 121
  • 1
    Is mod_rewrite enabled so you can use .htaccess? – Robin Dirksen Oct 18 '16 at 09:15
  • Please check what happens when you hit localhost/project/public/index.php/welcome – Vahe Galstyan Oct 18 '16 at 09:16
  • @VaheGalstyan its working with `localhost/project/public/index.php/welcome`... Why is that and how can i fix that. – Gammer Oct 18 '16 at 09:40
  • 1
    You should check apache configuration, enable mod_rewrite, after that for best practice please create virtual host, here is a link http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost and everything should work correctly. Reason is your apache configurations maybe mod_rewrite is disabled and .htaccess file dosent work. – Vahe Galstyan Oct 18 '16 at 10:08

4 Answers4

2

Has your route file been cached? See what happens when you run:

php artisan route:clear

and try again.

Jerre
  • 179
  • 2
  • 7
2

Laravel is case insensitive, so if you created the project with one of these will not find the path.

2

I was having some trouble with this myself, so for anyone having trouble with getting a Laravel route to work:

  1. Make sure your route is defined the correct way by running php artisan route:list Your route should show up, along with the method. (get, post, ...)
  2. Enable mod_rewrite from the Apache settings so Laravel can map /uri to whatever you like.
  3. Modify the .htaccess or Apache settings to allow url overrides: AllowOverride All If you are working on something like localhost/~username/yourproject, also check the username.conf file in /private/etc/apache2.

I'm not an expert in Apache settings, so feel free to correct or elaborate where needed.

Community
  • 1
  • 1
Bert H
  • 1,087
  • 1
  • 15
  • 29
0

goto htaccess in your laravel folder after ( RewriteEngine On ) add this

RewriteBase  /yourlaravel project name/public

example:
RewriteBase /laravel/public

Egyptionl
  • 63
  • 7