0
votes

I have a problem when I use routes in Laravel 5.0, I only need to call this route:

Route::get('home', 'HomeController@index');

But the browser shows me this, when I write http://localhost/course/public/home:

Not Found
The requested URL /course/public/home was not found on this server.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80

If I write http://localhost/course/public/ the index works but the other routes doesn't work, I don't know why.

In my Routes.php I have this:

Route::get('/', 'WelcomeController@index');

Route::get('home', 'HomeController@index');

Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
]);

I only downloaded laravel 5.0 with composer, I did not change nothing in the code after the download, I only want to test the routes and these don't work.

Thaks for your help.

1
Is there a controller named "public"?Gaurav Dave
Hello Gaurav Dave, the controller's name is "HomeController", public is the folder where the index is located.Steven Arturo Brenes González
Remove public from the url and go to /course/home insteadAndrew Smith
I did it but the error is the same.Steven Arturo Brenes González

1 Answers

0
votes

in conclusion (the comments solved the problem, so thank you guys for this!!) you probably run Laravel on Apache and you don't have mod_rewrite enabled... or not configured correctly.

Laravel works with so called pretty urls. In order to achieve this, every request is rewritten and the config you can find in the .htaccess file in the public folder. This to give a quick and dirty explanation will let you write URLs without the index.php.

Additionally your server should serve the public folder and not the main folder. That's a security thing if you want to use your site in production.

Alternatively you can use nginx which in my opinion is a lot easier to configure and if you run laravel homestead everything comes straight out of the box.