Create a RewriteRule
and return an empty file in response to the URLs you'd like to remove from the logs:
RewriteRule scores\.asp$ - [L]
In case you don't have any pattern for the URLs and you want to prevent for all non-existing files, add a RewriteCond
:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]
Or just with a more current apache:
FallbackResource /index.php
and then index.php
giving a 404 status response:
<?php
header("Status: 404 Not Found", 1, 404);
The index.php
file must exists, otherwise (for the RewriteRule
) this would create an endless loop.
Alternatively this might work (and won't require the index.php
file):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ - [R=404,L]
See: Apache2: how to avoid logging certain missing files into error.log