Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Routing Object Not Found

I ussualy using Laravel 4 and now Im trying to learn Laravel 5

there's problem on Naming Controller Routes :

i had route like :

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

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

when i run route as 'home' (localhost/laravel/) its work perfectly

but when i run route as 'event' (localhost/laravel/events): Object not found! enter image description here

and i already make sure that viewEvent method running right by swap it like this:

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

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

i can run viewEvent but i cant run viewHome

any problem with my code?

======================== SOLVED =============================

with help @DamienPirzy and i realize when i disable /public/ folder i think i must make .htaccess out to main folder too :)

thanks all for fast response :) Problem Solved

like image 814
GandhyOnly Avatar asked Apr 20 '15 07:04

GandhyOnly


2 Answers

Put this htaccess into public folder. make sure you have apache mod rewrite working.

<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>
like image 155
kamlesh.bar Avatar answered Sep 19 '22 23:09

kamlesh.bar


i saw in routes.php

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

But u run

localhost/laravel/event  

Should run

localhost/laravel/events
like image 39
Kornkrit Leelhaphunt Avatar answered Sep 19 '22 23:09

Kornkrit Leelhaphunt