And*_*ier 1 php error-handling .htaccess error-logging text-files
对于PHP错误处理,目的是"只有管理员才能看到警告,错误等";
我应用了以下步骤:
error_reporting(-1);了我的命令index.php.htaccess这是刚下public_html的文件夹error_modes在我的public_html文件夹中创建了文件夹.htaccess文件error_modes夹中创建了文件error_modes文件夹的权限设置为777可写.<?php 'should see this error in log file' ?>在我的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.
你能纠正我吗?谢谢.最好的祝福.
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
Run Code Online (Sandbox Code Playgroud)
Order allow,deny
Deny from all
Run Code Online (Sandbox Code Playgroud)
RewriteEngine 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
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# disable directory browsing
Options All -Indexes
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# secure password file
<Files .mypassword>
order allow,deny
deny from all
</Files>
# secure spesific files
<Files secret.php>
order allow,deny
deny from all
</Files>
# secure spesific files
<Files secret2.php>
order allow,deny
deny from all
</Files>
#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
Run Code Online (Sandbox Code Playgroud)
小智 7
请尝试执行以下操作:
# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_value docref_root 0
php_value docref_ext 0
# enable PHP error logging
php_flag log_errors on
php_value error_log /correct_path_to_your_website/error_modes/PHP_errors.log
# general directive for setting php error level
php_value error_reporting -1
Run Code Online (Sandbox Code Playgroud)
你在php文件中写的不是故意的错误,你可以尝试做类似的事情:
<?
echo $_SERVER['DOCUMENT_ROOT']; // this will enable you to see
// the correct path to your website dir
// which should be written in .htaccess
// instead of correct_path_to_your_website
// (check it just in case)
$foo = $bar['nope'];// this should generate notice
call_undefined(); // this should generate fatal error
?>
Run Code Online (Sandbox Code Playgroud)
和我一起工作)
希望它会有所帮助.
| 归档时间: |
|
| 查看次数: |
12755 次 |
| 最近记录: |