Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx skip WordPress 404 handling for static files
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
if ($request_uri ~ "(robots\.txt|sitemap\.xml(\.gz)?)") {
break;
}
if ($request_uri ~* \.(css|js|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$) {
return 404;
@adamscout162

This comment has been minimized.

Copy link

@adamscout162 adamscout162 commented Jan 24, 2020

Where does this code go to work?

@GeekPress

This comment has been minimized.

Copy link
Owner Author

@GeekPress GeekPress commented Jan 24, 2020

Into the NGINX configuration file.

@finalwebsites

This comment has been minimized.

Copy link

@finalwebsites finalwebsites commented Jan 31, 2020

Hi,

this should be a location directive in Nginx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment