0
protected function _initRoutes()
{
$this->router = $this->frontController->getRouter();
$route = new Zend_Controller_Router_Route(
':username',
array(
'module' => 'default',
'controller' => 'view',
'action' => 'profile',
'username' => ':username'
)
);
$this->router->addRoute('profile', $route);
}
什麼它應該做的是符合這樣的:這條路線有什麼問題?
http://www.mydomain.com/something
要:
http://www.mydomain.com/view/profile/username/something
其中一期工程。麻煩的是,當我去:
http://www.mydomain.com
我得到個aa數據庫錯誤是存在主要是因爲它匹配(和它不應該是):
http://www.mydomain.com/view/profile
但是,如果沒有用戶名,這是必需的。
路由在我的引導文件中定義。我應該怎麼做才能使它正常工作?
編輯:
看來問題是與我的意見中的網址助手。這些網址有什麼問題?
<?php
echo $this->url(array('module' => 'default',
'controller' => 'view',
'action' => 'profile',
'id' => $this->escape($m->id)),
null,
true);
?>
或者:
<?php
echo $this->url(array('module' => 'default',
'controller' => 'my-account',
'action' => 'write-message'),
null,
true);
?>
是的那條線完全沒用 – andho 2009-09-30 03:36:44
這不僅是無用的,而且是問題的原因。通過爲用戶名設置默認值,它將始終有一個值,這意味着此路線將始終匹配。 – linead 2009-09-30 05:00:53
當我刪除該行時,www.mydomain.com再次正常工作,但是當我訪問www.mydomain.com/username時,出現錯誤:「未指定用戶名」 – 2009-09-30 08:55:08