Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
Nginx rewrite local file path

Is it possible to make this kind of url rewrite?

Request url: https://image.domain.com/listing/1_10_iP2LROSEafC01584630756.jpg Rewrite to: https://image.domain.com/images/i/P/2/L/iP2LROSEafC01584630756.jpg

If /images/i/P/2/L/iP2LROSEafC01584630756.jpg exists in server, it's served, if not then query is redirected to php file /make_image.php

Thank you!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Request url: https://image.domain.com/listing/1_10_iP2LROSEafC01584630756.jpg Rewrite to: https://image.domain.com/images/i/P/2/L/iP2LROSEafC01584630756.jpg

If you mean an external redirect, then this is achieved using the rewrite directive. Place the statement in the server block, or within a location block that handles these kinds of request (i.e. URIs beginning with /listing/ and/or ending with .jpg).

Your question does not state what 1_10_ means, but let's assume that you want the two arbitrary numbers ignored.

For example:

rewrite ^/listing/\d+_\d+_(.)(.)(.)(.)(.*)$ /images/$1/$2/$3/$4/$5 permanent;

See this document for details.

If /images/i/P/2/L/iP2LROSEafC01584630756.jpg exists in server, it's served, if not then query is redirected to php file /make_image.php

This is achieved using a try_files statement within a location block that processes requests for URIs beginning with /images/.

For example:

location /images/ {
    try_files $uri /make_image.php;
}

See this document for details.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda