I have this route defined Route::resource('smn','smnController');
And this controller smnController
which as following code.
public function index()
{
return "hello";
}
In console when I type php artisan routes
, it displays
GET|HEAD smn | smn.index | smnController@index
along with many others.
In the url when I type http://localhost:8081/laravel/smn
, it displays error not found.
But when I change route to Route::resource('/','smnController');
, and url to http://localhost:8081/laravel/
it displays helo
.
Can anyone please explain this
EDIT
complete route and controller
<?php
Route::resource('smn','smnController');
?>
AND COntroller
<?php
class smnController extends BaseController {
public function index()
{
return "hello";
}
}
?>
in your VirtualHost please make sure your DocumentRoot
is pointing to public
DocumentRoot /var/www/laravel/public
If you're using a LAMP stack then you should enable the rewrite module, type sudo a2enmod rewrite
to enable that module, also make sure you are using the mcrypt extension of php typing sudo php5enmod mcrypt
and then restart the apache service sudo service apache2 restart
that should work
Try this..
Route::get('/', 'smnController@index');
class smnController extends BaseController {
public function index()
{
return "hello";
}
}