开发者

error.phtml is being displayed (Page not found error)

I am a beginner working with Zend Framework, and currently having a small problem:

I am creating a project based on modular architecture and requesting this URL:

http://localhost/MyApp/public/ --> which is where index.php resides. My core module is called "core" inside /application/modules directory as follows:

/Applications/modules/
-- Core
---- controllers
------ ErrorController.php
------ IndexController.php
---- views
------ scripts
-------- error/error.phtml
-------- index/index.phtml.

Everyt开发者_Python百科ime i refresh the page i get error.phtml displayed which is weird. Because my module does define it's routes as follows:

[routes]
routes.core_index_index.type = "Zend_Controller_Router_Route_Static"
routes.core_index_index.route = "/"
routes.core_index_index.defaults.module = "core"
routes.core_index_index.defaults.controller = "index"
routes.core_index_index.defaults.action = "index"
routes.core_index_index.defaults.frontend = "true"
routes.core_index_index.defaults.langKey = "route_index_page_description"
routes.core_index_index.defaults.localization.enable = "true"

Plus the fact that i do have RewriteBase set to /var/www/html/MyApp/public. So why is my error.phtml being displayed while index.phtml should be the view script to be rendered?

Following is my setup for production config in application.ini

phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.defaultModule = core
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.params.prefixDefaultModule = "1"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

Content of error page being displayed:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Zend Framework Default Application</title>
</head>
<body>
  <h1>An error occurred</h1>
  <h2>Page not found</h2>


</body>
</html>

Any help is truly appreciated.


index.php is the frontController. ModRewrite should send requests to MyApp/ to MyApp/public/index.php, meaning you shouldn't have to put the whole path in. I looks like there's an error in your setup which is why the ErrorController is being called rather than IndexController. What error do you get?


Your error.phtml doesn't show any stack trace. You got 2 simple ways to show it : - edit your .htaccess, and change the Application_env value :

SetEnv APPLICATION_ENV development

If you application_env is set to "production", all the exception's stack trace is masked.

The other way is to edit the error.phtml file, and remove the condition around the environment to always disply the stack trace. (not the best option though)

This is not the answer (yet) but you'll have much more input for your problems, most notably the request parameters.

edit : rewrote answer based on tries :)


Okay, i got this to work:

Since am requesting http://localhost/MyApp/public/, i had to modify the routing to:

[routes]
routes.core_index_index.type = "Zend_Controller_Router_Route_Static"
routes.core_index_index.route = "/MyApp/public/"
routes.core_index_index.defaults.module = "core"
routes.core_index_index.defaults.controller = "index"
routes.core_index_index.defaults.action = "index"
routes.core_index_index.defaults.frontend = "true"
routes.core_index_index.defaults.langKey = "route_index_page_description"
routes.core_index_index.defaults.localization.enable = "true"

Change was from:

routes.core_index_index.route = "/"

To:

routes.core_index_index.route = "/MyApp/public/"

Which is not exactly what i was looking for. Is there a way to skip /MyApp/public part of the URI?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜