问题
In my Zend Framework project I have the following base URL
http://domain/~myFolder
If I access it like so, I can access the indexAction with no problem but if I try to access it explicitly like so:
http://domain/~myFolder/index
I can't, nore can I access different controllers or actions. It always says
/public/index.php was not found on this server.
How can I access the different controllers and actions in my project? Do I need to add a route?
回答1:
Change the contents of the .htaccess
file according to...
From: http://framework.zend.com/manual/1.12/en/zend.application.quick-start.html
You may note that the application environment constant value looks for an environment variable "APPLICATION_ENV". We recommend setting this in your web server environment. In Apache, you can set this either in your vhost definition, or in your .htaccess file. We recommend the following contents for your public/.htaccess file:
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]
回答2:
I was able to access the controller page by putting the controller name after the index.php
:
ie: yoursite/public/index.php/ControllerName
It worked in my case.
来源:https://stackoverflow.com/questions/21235223/cant-access-controller-nore-action-in-zend-framework