Enabling error display in php via htaccess only

2019-01-03 01:53发布

I am testing a website online.

Right now, the errors are not being displayed (But I know they exist).

I have access to only the .htaccess file.

How do i make all errors to display using my .htaccess file

EDIT

I added these lines to my .htaccess:

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

and the pages NOW display

Internal server error

4条回答
Emotional °昔
2楼-- · 2019-01-03 02:11

If you want to see only fatal runtime errors:

php_value display_errors on
php_value error_reporting 4
查看更多
时光不老,我们不散
3楼-- · 2019-01-03 02:12

I feel like adding more details to the existing answer :

# PHP error handling for development servers
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /full/path/to/file/php_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0

Give 777 or 755 permission to the log file and then add the code

<Files php_errors.log>
     Order allow,deny
     Deny from all
     Satisfy All
</Files>

at the end of .htaccess. This will protect your log file. These options are suited for development server. For production server you should not display any error to the end user. So change the display flags to off.

For more info follow this link : Advanced PHP Error Handling via htaccess

查看更多
ゆ 、 Hurt°
4楼-- · 2019-01-03 02:26

.htaccess:

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log
查看更多
欢心
5楼-- · 2019-01-03 02:31
php_flag display_errors on

To turn the actual display of errors on.

To set the types of errors you are displaying, you will need to use:

php_value error_reporting <integer>

Combined with the integer values from this page: http://php.net/manual/en/errorfunc.constants.php

Note if you use -1 for your integer, it will show all errors, and be future proof when they add in new types of errors.

查看更多
登录 后发表回答