Is it possible to remove /index on default getIndex restful controller function?
Defined route for controller:
Route::controller('registration', 'RegisterController', array(
'getIndex' => 'getRegister'
));
Controller:
class RegisterController extends UserController {
public function getIndex()
{
// Show the register page
return View::make('register');
}
}
For example, in my login.blade.php i have:
{{ HTML::link(URL::route('getRegister'), 'New User?', array('title' => 'Novi korisnik?', 'class' => 'wideBtn', 'id' => 'userRegisterLink')) }}
and returned result is link like this: http://mydomain.com/registration/index
I prefer to get link URL over URL::route() with route name, and i want returned link to be simple as this: http://mydomain.com/registration
Thanks
In your routes.php file:
In any view:
And the rest of the controller methods are still mapped the same. Just make sure they are get routes (or if they need to be any/post methods). And that they are before the controller method mapping call. No more http://example.com/index links anymore!
You can use like,
Or,
Then you can access
index
byGET http://localhost/laravel/registration
like,Read documentation here.
The controller main functions will be
index, store, show, update, destroy