Обработка ошибок PHP с помощью .htaccess и запись в текстовый файл php_error.log
Для обработки ошибок PHP с целью "только админ видит предупреждения, ошибки и т. д. ";
Я применил шаги ниже:
я удалилerror_reporting(-1);
команда от моегоindex.php
Я добавил строки ниже в мой.htaccess
который находится подpublic_html
папкая создалerror_modes
папка в моемpublic_html
папкая создал.htaccess
файл вerror_modes
папкаЯ установил права доступаerror_modes
папка как777
, для записи.намеренно я написал
в моемfooter.inc.php
стр. Обратите внимание, что я нет написал;
персонаж в конце.Несмотря на преднамеренноеошибка синтаксиса php в моемfooter.inc.php
страница,нетphp_error.log
файл создан!
и я увидел этодолжна увидеть эту ошибку в файле журнала string
напечатано в моемfooter.inc.php
стр. Так что php работал несмотря на синтаксическую ошибку!
Я также добавил весь мой.htaccess
код ниже. (это тот, который чуть ниже)public_html
FYI: Я нене имеет доступа кphp.ini
и я нене имеет каких-либо предварительных настроек.log
файл. Версия PHP 5.4.
Можете ли вы исправить меня? Благодарю. С уважением.
добавлены команды в public_html> .htaccess для обработки ошибокphp_flag log_errors on
php_flag display_errors off
php_value error_log /home/my_user_number/public_html/error_modes/php_error.log
php_value error_reporting -1
коды в error_modes> .htaccessOrder allow,deny
Deny from all
целые коды в public_html> .htaccessRewriteEngine On
RewriteBase /
#always use www - redirect non-www to www permanently
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# hotlink protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.p.ht [NC]
RewriteRule \.(jpg|jpeg|png|gif|css|js)$ - [NC,F,L]
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# File caching is another famous approach in optimizing website loading time
Header set Cache-Control "max-age=2592000"
# disable directory browsing
Options All -Indexes
# secure htaccess file
order allow,deny
deny from all
# secure password file
order allow,deny
deny from all
# secure spesific files
order allow,deny
deny from all
# secure spesific files
order allow,deny
deny from all
#SEO friendly linking
RewriteRule ^sitemap.xml$ sitemap.php [L]
RewriteRule ^articles/(.+)/(.+)$ index.php?page=articles&subject=$1&object=$2 [L]
RewriteRule ^articles/(.+)$ index.php?page=articles&subject=$1 [L]
RewriteRule ^labels/(.+)$ index.php?page=labels&subject=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)$ index.php?page=$1 [L]
#error handling
php_flag log_errors on
php_flag display_errors off
php_value error_log /home/my_user_number/public_html/error_modes/php_error.log
php_value error_reporting -1