简体   繁体   English

Zend Framework 2多模块URL路由问题

[英]Zend framework 2 multiple module url routing issue

Am facing the issue when I have two or three module in my framework like 当我的框架中有两个或三个模块时,正面临这个问题

  • Album 专辑
  • Admin 管理员
  • User 用户

The way I can access the above module using URL is as follows 我可以使用URL访问上述模块的方式如下

But I want access the module in the following way 但是我想通过以下方式访问模块

I have checked on the following links but this dose not worked for me 我检查了以下链接,但这对我不起作用

Having trouble with URI routing for modules in Zend Framework Zend Framework中模块的URI路由遇到问题
Routing in Zend Framework 2 Zend Framework 2中的路由
Zend framework 2 module name routing issue Zend Framework 2模块名称路由问题
Zend Framework 2 - Multiple modules by URL Zend Framework 2-通过URL的多个模块
Zend Framework 2 routing issue Zend Framework 2路由问题
404 error, Zend Framework 2 The requested URL could not be matched by routing 404错误,Zend Framework 2请求的URL无法通过路由进行匹配

For removing the public I have managed by creating the Index.php at the root level of the project with the following code 为了消除公众,我通过使用以下代码在项目的根目录级别创建Index.php来进行管理

<?php 
    define('RUNNING_FROM_ROOT', true);
    include 'public/index.php';

Please help me if anyone has faced similar issue 如果有人遇到类似问题,请帮助我

You should not add your own index.php at root level. 您不应该在根级别添加自己的index.php You should delete this file again. 您应该再次删除该文件。 Your issue is that you should serve the application from your /public folder folder. 您的问题是您应该从/public文件夹文件夹中为应用程序提供服务。

It seems like you are currently serving from the ZF2 application root folder. 看来您当前正在从ZF2应用程序的根文件夹进行服务。 The recommended solution is to change your server settings to serve from /public instead. 推荐的解决方案是更改服务器设置以改为从/public服务。 In Apache you can do this for example using your virual host config. 例如,在Apache中, 您可以使用虚拟主机配置来执行此操作 It has a DocumentRoot param. 它具有DocumentRoot参数。

Otherwise check the answer to an alternative solution here . 否则,请在此处检查替代解决方案的答案

Solved the Issue 解决了问题

  • Removed both the index.php and .htaccess file from the root level 从根级别删除了index.php和.htaccess文件
  • set the virtual host from the zend document zend文档中设置虚拟主机
  • Followed the answer given on stackoverflow 遵循在stackoverflow上给出的答案

Configuration am using 配置正在使用

  • Ubuntu 14.04 Ubuntu 14.04
  • PHP 5.5.9 PHP 5.5.9
  • apache2 的Apache2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM