运行ZendFramework项目中的子目录 [英] Running a ZendFramework project inside a subdirectory

查看:146
本文介绍了运行ZendFramework项目中的子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ZendFramework的项目,我想里面的一个子目录中运行。

I have a ZendFramework project that I would like to run inside a subdirectory.

目前我的文档根目录是 /无功/网络,然后该项目是位于 /无功/网络/项目的各种文件夹(控制器公开的,等等)都在项目中目录。

Currently my document root is at /var/www and the project is at /var/www/project with the various folders (controllers, public, etc.) all within the project directory.

我试图让这个从 HTTP的所有请求:// Web服务器/项目/ *被传递到 /var/www/project/public/index.php 文件。然而,尝试使用下面的code中的 /var/www/project/.htaccess 以将所有请求传递不起作用:

I am trying to make it so that all requests from http://webserver/project/* are being passed to the /var/www/project/public/index.php file. However, trying to use the following code in /var/www/project/.htaccess to pass all requests does not work:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /project/public/index.php [NC,L]

还有在的.htaccess 文件 /无功/网络/工程/公共包含完全相同的code,但加载 /项目时, URL我只是$ psented与项目内容的目录索引p $。

There is also an .htaccess file in /var/www/project/public that contains exactly the same code, but when loading the /project URL I am just presented with a directory index of the project contents.

推荐答案

我要存储项目完全独立的文档根目录,例如 /家庭/用户/项目/工程

I'd store the project completely separate to the document root, for example /home/user/projects/project.

然后,只需符号链接 /无功/网络/项目 /家庭/用户/项目/工程/公共

Then, simply symlink /var/www/project to /home/user/projects/project/public.

只要你使用的baseUrl视图助手任何静态资产链接(JavaScript,图片,CSS等),它应该只是罚款。

Provided you use the BaseUrl view helper for any static asset links (JavaScript, images, CSS, etc), it should work just fine.

修改:另一个建议是从应用程序的其余部分分开的公共目录

Edit: Another suggestion is to separate your public directory from the rest of the application.

举例来说,假设你的项目是 /家庭/用户/项目/工程,将您的公开目录 /无功/网络/项目和编辑的index.php 具有以下

For example, say your project is in /home/user/projects/project, move the contents of your public directory to /var/www/project and edit index.php with the following

defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', '/home/user/projects/project/application');

这篇关于运行ZendFramework项目中的子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆