[英]php Zend framework 2 error 404 page
I was trying to add new error 404 page for my module. 我试图为我的模块添加新的错误404页面。 I have Application and my own Admin module. 我有应用程序和我自己的管理模块。 For Application I use default 404.phtml, for my new module I created admin404.phtml but I have no idea how to run it. 对于应用程序,我使用默认的404.phtml,对于新模块,我创建了admin404.phtml,但我不知道如何运行它。 There are a lot of options how to change layout for modules but I couldn`t find answer for my question. 有很多选项可以更改模块的布局,但是我找不到问题的答案。 Can anyone help me? 谁能帮我?
When a page could not be found or some other error happens inside of your web application, a standard error page is displayed. 当找不到页面或Web应用程序内部发生其他错误时,将显示标准错误页面。 The appearance of the error page is controlled by the error templates. 错误页面的外观由错误模板控制。 There are two error templates: error/404
which is used for "404 Page Not Found" error, and error/index
which is displayed when an unhandled exception is thrown somewhere inside of the application. 有两个错误模板:用于“ 404未找到页面”错误的error/404
和在应用程序内部某个地方抛出未处理的异常时显示的error/index
。
The module.config.php file contains several parameters under the view_manager
key, which you can use to configure the appearance of your error templates: module.config.php文件在view_manager
键下包含几个参数,您可以使用这些参数来配置错误模板的外观:
<?php
return array(
//...
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
//...
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
//...
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index'=> __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
display_not_found_reason
parameter controls whether to display the detailed information about the "Page not Found" error. display_not_found_reason
参数控制是否显示有关“找不到页面”错误的详细信息。 display_exceptions
parameter defines whether to display information about an unhandled exception and its stack trace. display_exceptions
参数定义是否显示有关未处理的异常及其堆栈跟踪的信息。 not_found_template
defines the template name for the 404 error. not_found_template
定义404错误的模板名称。 exception_template
specifies the template name for the unhandled exception error. exception_template
指定未处理的异常错误的模板名称。 You typically set the display_not_found_reason
and display_exceptions
parameters to false
in production systems, because you don't want site visitors see the details about errors in your site. 在生产系统中,通常将display_not_found_reason
和display_exceptions
参数设置为false
,因为您不希望站点访问者看到有关站点错误的详细信息。 However, you will still be able to retrieve the detailed information from Apache's error.log
file. 但是,您仍然可以从Apache的error.log
文件中检索详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.