【发布时间】:2016-04-15 15:17:09
【问题描述】:
当我的框架中有两个或三个模块时,我面临着这个问题
- 专辑
- 管理员
- 用户
我使用URL访问上述模块的方式如下
- 专辑 -> http://localhost/zf2
- 管理员 -> http://localhost/zf2/index.php/admin
- 用户 -> http://localhost/zf2/index.php/user
但我想通过以下方式访问模块
- 专辑 -> http://localhost/zf2
- 管理员 -> http://localhost/zf2/admin
- 用户 -> http://localhost/zf2/user
我已经检查了以下链接,但是这对我不起作用
Having trouble with URI routing for modules in Zend Framework
Routing in Zend Framework 2
Zend framework 2 module name routing issue
Zend Framework 2 - Multiple modules by URL
Zend Framework 2 routing issue
404 error, Zend Framework 2 The requested URL could not be matched by routing
为了删除公众,我通过使用以下代码在项目的根级别创建 Index.php 来管理
<?php
define('RUNNING_FROM_ROOT', true);
include 'public/index.php';
如果有人遇到类似问题,请帮助我
【问题讨论】:
-
看起来更像是 apache 或 nginx 路由的东西,而不是 php...?如果您运行 Apache,请检查您的重写引擎是否已打开并且重写规则是否在中。
-
@Raphioly-San:我也检查了重写引擎和重写规则,两者都到位。要我再检查一下吗?
-
检查rewrite模块是否被激活?根据您的配置方式,您可能需要检查您的 .htaccess 是否会覆盖您的虚拟主机配置中的设置。如果没有,请将
AllowOverride All添加到您的<Directory >节点(或如果存在则更改)。如果你在 Windows 上运行? Windows 有一个奇怪的功能,您可能需要设置... -
您应该从您的公用文件夹中提供应用程序。似乎您从 ZF2 应用程序根文件夹中提供服务。将您的服务器设置改为从
/public提供服务。否则请检查替代解决方案的答案here
标签: php zend-framework zend-framework2