/account ルートの下のページにアクセスするときに、強制的な https を実現しようとしています。この質問ZF2 toRoute with httpsを見つけましたが、うまくいきます...部分的に。私のルート:
'router' => array(
'routes' => array(
'account' => array(
'type' => 'Scheme',
'options' => array(
'route' => '/account',
'scheme' => 'https',
'defaults' => array(
'controller' => 'Account\Controller\Account',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Account\Controller\Account',
'action' => 'index',
),
),
),
'signin' => array(
'type' => 'Segment',
'options' => array(
'route' => '/signin[/:type]',
'defaults' => array(
'controller' => 'Account\Controller\Account',
'action' => 'signin',
),
'constraints' => array(
'type' => '[a-zA-Z][a-zA-Z0-9-_]*',
),
),
),
'signout' => array(
'type' => 'Segment',
'options' => array(
'route' => '/signout',
'defaults' => array(
'controller' => 'Account\Controller\Account',
'action' => 'signout',
),
),
),
'register' => array(
'type' => 'Segment',
'options' => array(
'route' => '/register[/:step]',
'defaults' => array(
'controller' => 'Account\Controller\Account',
'action' => 'register',
),
'constraints' => array(
'step' => '[a-zA-Z][a-zA-Z0-9-_]*',
),
),
),
),
),
),
),
およびスケルトン アプリケーション (github から複製) のアプリケーション モジュールからのホーム ルート。/account のサブルートにアクセスするたびに、404 がスローされます。
http(s)://domain.my/account/signin = 404, wrong
http(s)://domain.my/account/* = 404, wron
https://domain.my/signin = signin page, wrong should be /account/signin
http://domain.my/ = ok, main page
http://domain.my/account = 404, wrong
https://domain.my/ = wrong, account page should be main page
通常、私の問題は次のとおりです。ページにはhttpまたはhttps BUT /accountでアクセスする必要があり、サブルートにはhttpsのみでアクセスする必要があります。
編集
わかりました、chained_routes を試しましたが、これは私が達成したかったことではありません。私はこのようなことをしたい:
ユーザーがログインしていません: タイプ: http://domain.my/account -> https://domain.my/account/loginにリダイレクトされます (私は でこれを達成できることを知っています$authService->hasIdentity()
) その後、 https://domain.myにリダイレクトします/アカウント
タイプ: http://domain.my/account/login -> https://domain.my/account/loginにリダイレクト
タイプ: http://domain.my/account/edit -> https://domain.my/account/login にリダイレクトされ 、次にhttps://domain.my/account/editにリダイレクトされます
ログに記録されたユーザーと同じように、/account ルートから何かにアクセスすると、同じ URL にリダイレクトされますが、https が使用されます。