「管理者だけが警告やエラーなどを見る」ことを目的とした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 です。
訂正していただけますか?ありがとう。よろしくお願いします。
エラー処理のために 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 のコード > .htaccess
Order allow,deny
Deny from all
public_html > .htaccess 内のコード全体
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