How to access an ZF2 application without “public”

2019-07-28 04:18发布

I completed my project on ZF2, then uploaded it on shared hosting. I would like a folder for the zend app with all the files inside, and then in the document root I would like the files from the public folder to be visible, because I want my URIs to look like www.example.com (not www.example.com/public/).

3条回答
做个烂人
2楼-- · 2019-07-28 04:46

You can move the files inside /public to your webroot. However, please be aware that config files below your webroot are a security risk.

查看更多
再贱就再见
3楼-- · 2019-07-28 04:58

This one work.

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]
查看更多
对你真心纯属浪费
4楼-- · 2019-07-28 05:00

What I have done in those cases with ZF1 app is to throw an app directory in the document root and with your server's .htaccess equivalent made it not serve files from there (Deny from all). Then stick your gateway script into the document root and update the paths found in there including APPLICATION_ROOT and the path to the autoloader.

Hope this helps.

查看更多
登录 后发表回答