我的app/modules /中有三個模塊,分別名爲Application,Album和Shop。我想要使用HOSTANME /應用程序,HOSTNAME/album和HOSTNAME/shop訪問每個模塊。對於應用程序模塊,配置爲:遷移並升級ZF2後,路由無法工作
'router' => array(
'routes' => array(
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'AppliWcation\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
.........
),
},...
Application模塊下有多個控制器。通過這種方法,我可以訪問URL: http://www.myhostname.com/application/controllerName/actionName 這是其他兩個模塊的類似配置。
這工作在上個月初以前的T61 thinkpad。然後我在我新買的T410上重新安裝了Php/apache。我也拉最新的ZF2版本:
git log
commit 73e0de644789aa5b712c97f55c512c57c2b9ac76
Merge: 7c65991 d722da5
Author: Matthew Weier O'Phinney <[email protected]>
Date: Fri Oct 4 11:01:06 2013 -0500
Merge branch 'hotfix/version-composer'
Fix for issue introduced with #5191
但一切都不工作了。我檢查了error.log:
[Sun Oct 06 10:47:05 2013] [error] [client 127.0.0.1] File does not exist: /path/to/app../ChipShop/public/application
但是,它適用於默認路由http://www.myhostname.com。
在我的配置中是否有任何錯誤或某些配置規則已更改?由於
[UPDATE]
有類似的帖子ZF2 routing configuration,我試過的方法:
'user' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'Application\Controller\User',
'action' => 'some-action',
),
),
) ,
但它仍然不是爲我工作..
SOLUTION問題不在代碼方面。這是在我的配置。 1,我忘了啓用apache重寫模塊。正如阿康博文所說的那樣。 2,在虛擬主機confiuration,
AllowOverride None
應改爲
AllowOverride All
它沒有解決問題。它仍然存在.. –
我更新了答案。 – akond
我已修復它..謝謝..錯誤消息顯示它是apache配置問題..只是類似於你所指的。:) –