Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
Nginx deploy static file in dynamic sub folder

My website root (/var/www/static.website.ext/public_html) is organized as follows:

images
|___ 61
     |___ 6105495099f49473.png
|___5f
     |___ 5fb969a00a4832d2.png
schema
|___ satic_file.png

As you can see the folders "61" and "5f" are generated dynamically (when loading the static file) from the name of the image. (first two characters)

My goal is the following:

https://static.website.ext/images/6105495099f49473.png  = display 6105495099f49473.png image (located in /images/61/61...)

How can I do in Nginx ? In Apache just use mod_rewrite, or alternatively mount an index.php file in the /images/ folder with a dispatcher.

But the performance would not be (I guess) like distributing directly from Nginx

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Use a regular expression location to capture the parts of the URI you require to build the path to the files. See this document for details.

For example:

root /var/www/static.website.ext/public_html;

location ~ ^(/images)(/..)(.*)$ {
    try_files $1$2$2$3 =404;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda