Can't access controller nore action in Zend Framework

余生颓废 提交于 2020-01-16 19:16:15

问题


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

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