H
H
HeartOfProgrammer2016-01-04 12:33:38
Laravel
HeartOfProgrammer, 2016-01-04 12:33:38

Why is router not working in laravel 5?

I created a site view with the file name index.blade.php
I also created a controller for it:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class HomeController extends Controller
{
    public function index()
    {
        return view('index');
    }
}

Set up the router like this:
<?php
Route::get('/', ['uses' => '[email protected]', 'as' => 'home']);
?>

I'm trying to go to my local site, and it just gives out all the files in the folder of my site.
The question is what did I enter wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2016-01-04
@alexey-m-ukolov

The problem is clearly not in Laravel - your web server is crookedly configured. Most likely, the DocumentRoot does not look in the public folder of the site, but one level higher.

S
Stanislav Pochepko, 2016-01-04
@DJZT

Most likely you don't have a .htaccess file in the root of your project. You need to specify a redirect to the /public folder. There you have the starting index.php file.

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question