1

I'm a beginner in frame work Laravel, I'm using Laravel 5.3 - I created a new project - laravel-. - It run fine on URL "http://localhost/laravel/public/" - I added a new route called "home" in web.php file as:

<?php
Route::get('/', function () {
    return view('welcome');
});
Route::get('/home', function () {
    return 'This is home.';
});

Not Found The requested URL /laravel/public/home was not found on this server.

Where is the problem? thank you.

Ahmed Mohammed
  • 337
  • 3
  • 16

4 Answers4

3

You're using wrong configuration. You should point web server to a public directory:

DocumentRoot "/path_to_laravel_project/public"
<Directory "/path_to_laravel_project/public">

And then use normal URLs like:

http://localhost
http://localhost/home
Community
  • 1
  • 1
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
3

In development phase the easy way around is using "php artisan serve" command. After you deploy the project, you should configure your server's document root as Alexey suggested.

0

try

Route::get('/home', function () {
    return 'This is home.';
});

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

Also call it like

http://localhost/laravel/home
Dev
  • 6,570
  • 10
  • 66
  • 112
0

Changing the .env.example file in the root project folder to .env worked for me.

Then generate a new APP_KEY using php artisan key:generate

daviek19
  • 21
  • 1
  • 5