I'm writing a Zend Framework application and its not a big deal but I can't figure out (even after googling) how to remove the /index/ from the url
So I currently have this
http://myapplication.local/index/home
When I really want
http://myapplication.local/home
I understand it may be possible to do this via the .htaccess?
The issue occurs because Zend by default uses controller/action urls (which is a default route). Because your root controller is IndexController
and the action is IndexController::homeAction
it is accessed via index/home
.
The easiest way to do what you want is adding routes to the application.ini
as follows:
resources.router.routes.home_route_or_any_name.route = "home"
resources.router.routes.home_route_or_any_name.defaults.module = "default"
resources.router.routes.home_route_or_any_name.defaults.controller = "index"
resources.router.routes.home_route_or_any_name.defaults.action = "home"
You can change home_route_or_any_name
to anything you want. You can also add many routes definitions to fit your needs.
For more information refer to Zend Framework Documentation
You can try this in bootstrap.php
/**
* Setup Routig.
* Now all calls are send to indexController like
* URL/ACTION-1
* URL/ACTION-2
*
* @return void
**/
protected function _initRouters()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$route = new Zend_Controller_Router_Route(
':action/*',
array(
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('default', $route);
}
I will remove index from all the action generated from indexController.
OR
in application.ini
routes.index.type = "Zend_Controller_Router_Route"
routes.index.route = "/"
routes.index.defaults.module = "default"
routes.index.defaults.controller = "index"
routes.index.defaults.action = "index"
For molre detail on routing you can read here