没有 Vhost 配置的 Zend Framework 2 [英] Zend Framework 2 without Vhost configuration
问题描述
我已经使用 Zend Framework 2 完成了我的第一个 Web 应用程序,我即将把它放到网上.但是可能网络主机不允许我更改我的虚拟主机配置!.htaccess 文件是允许的.
I had finished my first web application using Zend Framework 2 and I'm about to put it online. But may web host doesn't allow me to change my vhost configuration! The .htaccess file is allowed.
所以我的问题是:如何仅使用 .htaccess 文件设置我的 ZF2 应用程序?
So my question is: How to set up my ZF2 app with only .htaccess files?
推荐答案
假设您有一个基于骨架的标准 ZF2 应用程序,然后尝试在根目录中创建一个 .htaccess
文件,其中包含 this:
Assuming you have a standard ZF2 application based of the skeleton, then try creating a .htaccess
file in the root with this in it:
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]
我没有测试过这个,但理论上,这应该有效地将文档根目录移动到公共目录,同时将其保留在 url 之外.
I haven't tested this, but in theory, this should effectively move the document root to the public directory while keeping it out of the url.
这篇关于没有 Vhost 配置的 Zend Framework 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!