Routing object not found

I am using Laravel 4 and now Im trying to find out Laravel 5

There is a problem with Naming Controller routes:

I had a route like:

Route::get('/', [
    'uses' => 'HomeController@viewHome', 
    'as' => 'home'
]);

Route::get('/events', [
        'uses' => 'EventController@viewEvent', 
        'as' => 'event'
    ]);

when I run the route as "home" (localhost / laravel /), its work fine

but when I run the route as an "event" (localhost / laravel / events): the object was not found! enter image description here

and I’ve already made sure that the viewEvent method works correctly by swapping it like this:

Route::get('/', [
    'uses' => 'EventController@viewEvent', 
    'as' => 'home'
]);

Route::get('/events', [
        'uses' => 'HomeController@viewHome', 
        'as' => 'event'
    ]);

I can start viewEvent, but I can not start viewHome

any problem with my code?

======================== SOLUTION =========================== =================================================== =====

using @DamienPirzy, and I understand that when I disable / public / folder, I think I should do .htaccess in the main folder as well :)

Thank you all for the quick reply :) The problem is solved

+4
5

htaccess . , apache.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
+3

routes.php

Route::get('/events', [
        'uses' => 'EventController@viewEvent', 
        'as' => 'event'
    ]);

u run

localhost/laravel/event  

localhost/laravel/events
+2

Can you check the .htaccess file? Because the screen error is from Apache. The request did not get into the Laravel application.

or is mod_rewrite validation enabled or not?

+2
source

try changing the .htaccess file to this

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
0
source

Copy the htacess file from the shared folder and paste it into the root directory. He must solve the problem, and also check the spelling of all routes; they must be correct.

0
source

All Articles