Search code examples
laravellaravel-4laravel-5

Laravel routes are not working on live server


I just found the problem on server. all is working fine in my localhost, but on live server, ONLY the home page route is working.

My directory is:

laravel-
        css
        js
        local->
             app
                 HTTP->
                      Controllers->
                                Homecontroller
                                 admin->
                                        Groupcontroller   
             config
              ...

Here is my htacess

<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]
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

And my route file is:-

Route::get('/group/detail', 'Groupcontroller@index');
Route::get('/group/add', 'Groupcontroller@create');
Route::get('/group/edit/{id}', 'Groupcontroller@edit');

http://www.example.com/home

My home controller is working.I think issue is with admin folder???

http://www.example.com/admin/group/detail

This is not working

Error is encountered :-

Class App\Http\Controllers\Admin\Groupcontroller does not exist

Please help me,Working fine at localhost but not on live. Thanks in advance


Solution

  • Path of Groupcontroller is Controllers/admin/Groupcontroller. So in your routes you need to access Groupcontroller with appropriate path.

    Route::get('/group/detail', 'admin\Groupcontroller@index');
    Route::get('/group/add', 'admin\Groupcontroller@create');
    Route::get('/group/edit/{id}', 'admin\Groupcontroller@edit');
    

    Also it is recommended to use CamelCase folder names. that is; change admin => Admin.