我在最后使用另一个变量链接一些路由时遇到问题。我正在使用通配符子域。像这样:http://eric.mysite.dev/mypage1 mypage1 将是一个 GET 变量。所以我想要的是http://mysite.dev/donate/now/index/id/eric/pagename/mypage1
如果没有这样的页面名称,我可以正常工作:
$router=$fc->getRouter();
// Host routes
$accountHostRoute = new Zend_Controller_Router_Route_Hostname(':urlname.mysite.dev', array('module' => 'donate', 'controller' => 'now', 'action' => 'index'), array('urlname'=>'(?!www$).*')
);
// Account routes
$router->addRoute('donateWithHostNameLocal', $accountHostRoute->chain(
new Zend_Controller_Router_Route_Hostname(
':urlname.mysite.dev',
array(
'module' => 'donate',
'controller' => 'now',
'action' => 'index'
)
)
));
但我也想要页面名称,所以我尝试了这个但它不起作用:
// Account dynamic pages routes
$router->addRoute('donateWithHostNamePageNameLocal', $accountHostRoute->chain(
new Zend_Controller_Router_Route_Hostname(
':urlname.mysite.dev/:pagename',
array(
'module' => 'donate',
'controller' => 'now',
'action' => 'index'
)
)
));
我收到以下应用程序错误:消息:找不到资源“默认:mypage1”
堆栈跟踪:0 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend/Acl.php(751): Zend_Acl->get('default:mypage1') 1 /Applications/MAMP /htdocs/mysite/application/modules/default/plugins/AccessCheck.php(15): Zend_Acl->isAllowed('guest', 'default:mypage1', 'index') 2 /Applications/MAMP/bin/php5/lib /php/ZendFramework-1.9.6/library/Zend/Controller/Plugin/Broker.php(309): Plugin_AccessCheck->preDispatch(Object(Zend_Controller_Request_Http)) 3 /Applications/MAMP/bin/php5/lib/php/ZendFramework- 1.9.6/library/Zend/Controller/Front.php(933): Zend_Controller_Plugin_Broker->preDispatch(Object(Zend_Controller_Request_Http)) 4 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend /Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch() 5 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run() 6 /Applications/MAMP/htdocs/mysite/ public/index.php(34): Zend_Application->run() 7 {main}
请求参数:数组('controller' => 'mypage1', 'action' => 'index', 'module' => 'default', )