【发布时间】:2014-01-17 05:10:11
【问题描述】:
我想从索引控制器生成的每个操作中从 url 中删除索引词。
domain.com/index/user/id/1
它应该是 domain.com/user/id/1
和
domain.com/index/home
应该是 domain.com/home
我该怎么做?如果您有解决方案,请告诉我。
我正在使用 zf1.12
【问题讨论】:
标签: php mysql .htaccess zend-framework
我想从索引控制器生成的每个操作中从 url 中删除索引词。
domain.com/index/user/id/1
它应该是 domain.com/user/id/1
和
domain.com/index/home
应该是 domain.com/home
我该怎么做?如果您有解决方案,请告诉我。
我正在使用 zf1.12
【问题讨论】:
标签: php mysql .htaccess zend-framework
您可以在您的 Bootstrap.php 中执行此操作(尽管在 application.ini 中)。将此添加到 Bootstrap:
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);
}
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"
【讨论】: