if ($request_filename !~* \.(gif|html|jpe?g|png|ico|js|css|flv|swf|pdf|xml)$ ) {
return 404;
break;
}
The request filename is checked against that regular expression which looks for all endings of filenames you want. If it does not match, Nginx will display a 404 (not found) page. This snippet should be used in the config file before any other rewrite rules or checks.about security, BSD, open source and programming.