Zend Framework 2 without Vhost configuration

只愿长相守 提交于 2019-11-30 07:37:24

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]

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!