I want to prevent Apache from logging "File does not exist" errors for certain irrelevant non-existing files that are often requested, such as "apple-touch-icon-120x120.png". These log entries clutter my log and make it difficult to see "real" problems. This is what I came up with:
RewriteCond %{REQUEST_URI} ^/apple-touch-icon(-\d+x\d+)?(-precomposed)?\.png$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ - [redirect=404]
The idea: If the file requested isn't a regular file and it isn't a symbolic link either, the RewriteRule will cause the error not to be logged. That kind of works.
Now I'm facing the following problem: If I actually create a symbolic link named "apple-touch-icon-120x120.png", then my RewriteRule still fires and I get 404. Without the rule or when I make the file a regular file and not a symbolic link, the file is served correctly. I thought that by using the !-l flag I could make my rule fire only if the requested file is not a regular file and it is not a symbolic link either. But that doesn't seem to work ...
I don't see anything suspicious in Apache's error log. What might I be doing wrong here?