Php Zend framework 2 https链接不工作
网站链接: 问题: 1号在工作,2号出现404错误 问题在于HTTP站点工作正常。但使用HTTPS时,只有默认控制器工作,而其他控制器不使用HTTPS: 下面是我的module.config.phpPhp Zend framework 2 https链接不工作,php,zend-framework,zend-framework2,Php,Zend Framework,Zend Framework2,网站链接: 问题: 1号在工作,2号出现404错误 问题在于HTTP站点工作正常。但使用HTTPS时,只有默认控制器工作,而其他控制器不使用HTTPS: 下面是我的module.config.php <?php return array( 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Zend\Mvc
<?php
return array(
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
// The following is a route to simplify getting started creating
// new controllers and actions without needing to create a new
// module. Simply drop new controllers in, and you can access them
// using the path /application/:controller/:action
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/', //edited by koushik
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[:controller[/:action]][/:id][/:pId][/:devId]', //edited by koushik
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'service_manager' => array(
'abstract_factories' => array(
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
'Zend\Log\LoggerAbstractServiceFactory',
),
'aliases' => array(
'translator' => 'MvcTranslator',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Developer' => 'Application\Controller\DeveloperController', // edited by Poulami
'Application\Controller\Template' => 'Application\Controller\TemplateController', // edited by Poulami
'Application\Controller\Admin' => 'Application\Controller\AdminController',
'Application\Controller\Frontend' => 'Application\Controller\FrontendController',
'Application\Controller\Ajaxcall' => 'Application\Controller\AjaxcallController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),// Added by Baishakhi
// Placeholder for console routes
'console' => array(
'router' => array(
'routes' => array(
),
),
),
);
有没有人可以帮助我并给我解决方案?zend在尝试查找路由器配置的路由匹配时,不管使用什么url方案 我认为您的问题在于您的apache配置中,您的https vhost不允许公用文件夹中的.htaccess文件 当所有URL都失败并且index.php正常工作时,这表明存在重写问题。检查您的apache配置,确保您的公用文件夹可以使用该选项覆盖htaccess文件 AllowOverride All如果要在路由中使用https,则需要使用Zend\Mvc\Router\Http\Scheme路由器。您只需在路由配置中添加一个选项:“scheme”=>“https” 您可以遵循以下简单示例:
'router' => array(
'routes' => array(
'name_route' => array(
'type' => 'Scheme', //<-----add the type Schema here.
'options' => array(
'route' => '/url',
'scheme' => 'https', //<-----specify this here.
'defaults' => array(
//set the default options here.
),
),
),
// ....
),
),
你也可以看到这一点
希望这有帮助 谢谢@jww的帮助。但是你能给我一些解决方案吗?你试过使用一种方案路线吗?例如:是的,我已经准备好尝试使用这个模式路由设置。但它不起作用。