Apache 2.4 Rewrite 404 errors log
- Create 1 conf file in apache :
$ nano /etc/apache2/conf-available/rewrite-log-404.conf
- Paste this code inside /etc/apache2/conf-available/rewrite-log-404.conf
RewriteEngine On
# exclude directory index
RewriteCond %{REQUEST_URI} !/index\.(php|html?)$
# exlcude auto-index of directories
RewriteCond %{REQUEST_URI} !/$
# if the request is not a file, directory, or symlink
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# set the "notfound" environment variable
RewriteRule ^ - [E=notfound:true,L]
# LogFormat Vhost log
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %X" vhost_combined
CustomLog /var/log/apache2/error.log vhost_combined env=notfound
CustomLog /var/log/apache2/requests.log vhost_combined env=!notfound
- Activate conf with:
$ a2enconf rewrite-log-404
-------------------------------
by 🅴🆁🆁🅴🆄🆁32
Hosted on
🅴🅲🅷🔵🆂🆈🆂🆃🅴🅼