Skip to content

Instantly share code, notes, and snippets.

@broland07
Created November 10, 2022 18:24
Show Gist options
  • Save broland07/1ebc37685ee0e8d97530df6d4014efaa to your computer and use it in GitHub Desktop.
Save broland07/1ebc37685ee0e8d97530df6d4014efaa to your computer and use it in GitHub Desktop.
nginx location block with regex if you want create subdirectories with the first letter from the file name.(It not contains accent characters.)
location ~ ^(/images/)([A-Za-z0-9_\-!~$.])([A-Za-z0-9_\-!~$.]*\.[A-Za-z0-9_\-!~$.]+)$ {
try_files $uri $1$2/$2$3 =404;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment