With Nginx, I intercept 404 errors for some JS file in a folder, and redirect to a PHP script that try to create / return the good file, with response code 200 in case of success.
But Nginx continues to write in error.log because the first attempts return a 404 header.
Can I disable this writing if the redirection leads to a 200 response code ?
My configuration in Nginx for these files :
location /assets/js/minified/ {
error_page 404 /index.php?controller=404&action=create_js;
}
Thanks !
I guess
try_filesis a better fit for your use caseSee the documentation
Otherwise (in case you don’t like
try_filesfor any reason), there islog_not_founddirective that disables writing 404s into error.log.