我有大量旧路线,需要将其重定向到新路线。
我已经在 Bootstrap 中定义了我的自定义路由:
protected function _initRoutes()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$oldRoute = 'old/route.html';
$newRoute = 'new/route/*';
//how do I add a 301 redirect to the new route?
$router->addRoute('new_route',
new Zend_Controller_Router_Route($newRoute,
array('controller' =>'fancy', 'action' => 'route')
));
}
如何添加使用 301 重定向将旧路由重定向到新路由的路由?
最佳答案
我就是这样做的
- 添加 Zend_Route_Regexp 路由作为旧路由
- 为旧路由添加 Controller 和操作
- 添加逻辑来解析旧路由
- 为此逻辑添加
$this->_redirect($url, array('code' => 301))
关于zend-framework - Zend 框架 : How to 301 redirect old routes to new custom routes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4229204/