Running Zend Framework in a subfolder - Problems with default controller
I am starting a Zend application and I need to put it in a sub folder like this:
- /subfolder
- application
- public ...
I did the following:
- I set the base url in application.ini:
resource开发者_Go百科s.frontController.baseUrl = "/subfolder"
- I moved the .htaccess from the public folder directly into /subfolder, while changing the htaccess as follows:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ public/index.php [NC,L]
That's all I did. And everything works as expected. I can add controller blog with action view and can access it by calling:
/subfolder/blog/view
the url view helper and stuff work right too. The only thing that does not work is the default controller. So when I enter:
/subolder/
I get 403 (forbidden). If I enter
/subfolder/index
...it works. What am I missing?!
Thanks in advance! teebee
you do not need to make any change in your zf public folder, just create an .htaccess file into the "/subfolder" directory with the following lines
# Rewrite rules
RewriteEngine on
RewriteRule (.*) ./public/$1
Replace RewriteRule ^.$ public/index.php [NC,L] with RewriteRule ^.$ http://addressto/index.php [R=302,NC] or RewriteRule ^.*$ /public/index.php [NC,L]
i'm not sure if putting ZF folders other than public into publicly accessible folder is right.It will impose your site on security flaws. You must put ZF'S public folder' contents into your server`s public folder and put other folders into a non-publicly accessible folder.If you need more that one instance of your ZF application you may use Zend module system.Please refer to zend online documentation for more details.
精彩评论