在只能访问公共目录的主机上安装 Zend 项目

发布于 2024-12-20 02:58:46 字数 1002 浏览 0 评论 0原文

我在 Ubuntu 上开发了一个基于 Zend Framework 的项目。我在本地机器上创建了一个虚拟主机进行测试。它在我的本地机器上完美运行。这是本地计算机上的虚拟主机的条目。

<VirtualHost *:80>
    ServerName example.dev
    DocumentRoot /var/www/example/public/
    <Directory /var/www/example/public/>
        AllowOverride All
    </Directory>
</VirtualHost>

问题:

我的问题是,当我购买域名(example.com)名称和托管时,他们给了我以下 ftp 目录来上传我的内容。

example.com 指向 /www.example.com/web/content

但我需要 example.com 指向 /www .example.com/web/content/public

我要求他们解决这个问题,但他们告诉我这是不可能的。有没有任何编程/配置解决方案。

谢谢

编辑:

我已经在 /www.example.com/web/content/public 中关注了 .htaccess

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

I developed a project on Zend Framework on Ubuntu. I created a virtual host on my local machine for testing. It is working perfectly on my local machine. This is the entry for virtual host on local machine.

<VirtualHost *:80>
    ServerName example.dev
    DocumentRoot /var/www/example/public/
    <Directory /var/www/example/public/>
        AllowOverride All
    </Directory>
</VirtualHost>

Problem:

My problem is that when I purchased domain(example.com) name and hosting they gave me following ftp directory to upload my content.

example.com is pointing to /www.example.com/web/content

But I need example.com to point/www.example.com/web/content/public

I asked them to solve it but they told it is impossible. Is there any programing/configuration solution of this.

Thanks

Edit:

I have already following .htaccess in /www.example.com/web/content/public

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

才能让你更想念 2024-12-27 02:58:46

根据他们使用的 Web 服务器和他们拥有的配置,您也许能够覆盖某些配置,例如,您可以使用 apache 重写规则和 .htaccess 文件更改文档根目录,如下所示放在 /www.example.com/web/content 的根目录下

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteRule ^$ /public/index.php [L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

Depending on the web server they use and the configuration they have you may be able to override some of the configuration, for example, you can change document root with apache rewrite rules with a .htaccess file like this one to put under the root of /www.example.com/web/content

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteRule ^$ /public/index.php [L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]
情场扛把子 2024-12-27 02:58:46

将index.php文件放入public文件夹中
并将 .htaccess 放在根文件夹中,巫婆内容

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

Options -Indexes

put index.php file into the public folder
and put .htaccess in the root folder, witch contents

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

Options -Indexes
落日海湾 2024-12-27 02:58:46

这很简单,只需将公共目录内容移至父目录,以便 /www.example.com/web/content/public 中的所有文件
成为
/www.example.com/web/content

并且不要忘记编辑 index.php 文件中的包含路径以使用新位置

it is straightforward , just move public directory contents to the parent so all files in /www.example.com/web/content/public
become on
/www.example.com/web/content

and don't forget to edit include path inside index.php file to work with the new location

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文