4

So, whenever a user tries to fetch a file on my Apache server that doesn't exist I get a 404 line in the Access log:

[29/Sep/2010:12:14:45 +0200] "GET /asdf HTTP/1.1" 404

And I also get this in the Error log:

[Wed Sep 29 12:14:45 2010] [error] [client] File does not exist: /www/site/asdf

Is there a way to suppress 404 erros from showing up in the error log- only in the access log?

1

ErrogLog(http://httpd.apache.org/docs/2.2/mod/core.html#errorlog) have not conditional. You can send the logs to syslog or script and filter it.

0

Yes, you can suppress them from the error log, but still have them in the access log. Just add these lines to .htaccess:

# Don't log missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(content\asdf)$ - [R=404,L]

It uses mod_rewrite.

RewriteCond is there to make sure that file indeed doesn't exist. Files that do exist will be served as usual.

R=404 says to send 404 Not Found status code when client accesses any files that contain "asdf". You need to modify the expression in parenthesis, on the last line, to suit your needs.

This answer is also found here.

-1

Try experimenting with LogLevel directive (http://httpd.apache.org/docs/current/mod/core.html#loglevel). It's not exactly what you want, but it can suit you needs, nevertheless

1
  • LogLevel seems to be set to always be notice when logging to a flatfile, though... :(
    – Sandman
    Sep 29 '10 at 14:01
-1

Error 404 is defined in defined in httpd.conf or .htacces like so:

ErrorDocument 404 /404.html

You can redirect to index page :

ErrorDocument 404 /index.html

or you can create a blank page blank.html and change config to : ErrorDocument 404 /blank.html

1
  • 3
    I don't think you understand the question.
    – cwd
    Nov 9 '11 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.