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

193
Visualizações
NGINX rewrite regex not working correctly

community, I have a Problem and I can't find a solution. I have a website running in which you can open things. You can use the path: https://localhost/open/index.htmp?id=1234 (or without the index.html in the URI). I want to open it throughout the path https://localhost/open/1234, so I set up a NGINX rewrite-rule:

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

This rule, redirected me many times, so my path looked like /open/?id=&id=&id=&id=&id=1234 I also tried:

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

None of them worked. What have I done wrong?

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

0

You do not need and cannot use the (?!\?id=.*) part in the rewrite directive, as Nginx uses a normalised URI when matching location, try_files and rewrite directives.

You could focus the regular expression to only match numeric IDs, for example:

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

The regular expression operator + is the same as {1,}.

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