Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
La expresión regular de reescritura de NGINX no funciona correctamente

comunidad, tengo un problema y no puedo encontrar una solución. Tengo un sitio web en ejecución en el que puedes abrir cosas. Puede usar la ruta: https://localhost/open/index.htmp?id=1234 (o sin index.html en la URI). Quiero abrirlo a lo largo de la ruta https://localhost/open/1234 , así que configuré una regla de reescritura NGINX:

 rewrite "^/open/(?!\?id=.*)(.{1,})$" /open?id=$1 permanent; (I also tried last instead of permanent)

Esta regla me redirigió muchas veces, por lo que mi ruta parecía /open/?id=&id=&id=&id=&id=1234 También probé:

 try_files $uri $uri/ /?id=$request_uri

Ninguno de ellos funcionó. ¿Qué he hecho mal?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No necesita ni puede usar la parte (?!\?id=.*) en la directiva de rewrite , ya que Nginx usa un URI normalizado al hacer coincidir las directivas de location , try_files y rewrite .

Puede enfocar la expresión regular para que solo coincida con ID numéricos, por ejemplo:

 rewrite ^/open/(\d+)$ /open/?id=$1 permanent;

El operador de expresión regular + es lo mismo que {1,} .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!