我可以隐藏使用的.htaccess在PHP错误的路径 [英] Can I hide the path in php error using .htaccess

查看:111
本文介绍了我可以隐藏使用的.htaccess在PHP错误的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以隐藏在PHP错误的路径使用的.htaccess

例如:

 注意:未定义的变量:你好在C:\ XAMPP \ htdocs中\ mysite的\的index.php上线3
 

我想用的.htaccess或打印东西要隐藏的路径让我知道,如果有没有打印错误页面的路径:

 注意:未定义的变量:个招呼就行3
 

 注意:未定义的变量:你好
 

 有错误在您的网页
 

修改

我把这个线在我的.htaccess 但我不能访问我的网站。有错误内部服务器错误 我怎样才能解决这个问题。

 #苏preSS PHP错误
的php_flag display_startup_errors关闭
的php_flag display_errors设置关闭
的php_flag html_errors关闭
php_value docref_root 0
php_value docref_ext 0
 

解决方案

PHP的错误消息并不意味着用户,但仅用于开发。

因此​​,对于生产环境中,应禁用的display_errors ,以避免信息泄露:

  

注意:[的display_errors 的]是一种功能来支持你的发展,不应该被用来生产系统(例如系统连接到互联网)

相反,你应该表现出一般错误信息给用户的不揭开内部的任何东西,只记录错误信息(见的 log_errors 和的 的error_log >):

  

注意:你强烈建议使用错误日志代替错误显示对生产网站

如果你真的想要修改PHP的错误信息,您可以使用 的set_error_han dler 设置自定义错误处理程序。

参见 OWASP的开发指南的关于错误处理,审计和日志记录了解更多信息。

Can I hide the path in php error using .htaccess

Example:

Notice: Undefined variable: hello in C:\xampp\htdocs\mysite\index.php on line 3

I want to hide the path using .htaccess or print something let me know if there is an error without print the path of the page:

Notice: Undefined variable: hello on line 3

or

Notice: Undefined variable: hello

or

There is error in your page

Edit :

I put this lines in my .htaccess But I can't access to my site. There is error "Internal Server Error" How Can I fix that

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0

解决方案

PHP’s error messages are not meant for users but for developers only.

So for a production environment, you should disable display_errors to avoid information disclosure:

Note: [display_errors] is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet).

Instead, you should show generic error messages to your users that do not unveil anything of the internals and only log the error messages (see log_errors and error_log):

Note: You're strongly advised to use error logging in place of error displaying on production web sites.

And if you really want to modify PHP’s error messages, you can use set_error_handler to set a custom error handler.

See also OWASP’s Development Guide on "Error Handling, Auditing and Logging" for further information.

这篇关于我可以隐藏使用的.htaccess在PHP错误的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆