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

127
Visualizações
Apache RewriteRule allow blank after slash or specified values

I need help with the following Apache RewriteRule

RewriteRule ^(customers)/(active|create)/?$ /mod/customers/?type=$2 [NC,L]

This rule works only if there's something after the / Eg: http://example.com/customers/active

It won't work if the url is http://example.com/customers

How can this RewriteRule be written so http://example.com/customers will work, as well as http://example.com/customers/active

/customers followed by nothing, or /customers followed by /active or /create

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

0

You can use this regex:

^(customers)(?:/(active|create))?/?$

It uses an optional non-capturing group to allow for a URL such as http://example.com/customers as well as http://example.com/customers/active. The `active|create is still captured in group 2.

Demo on regex101

This regex allows for a trailing / on the URL e.g. http://example.com/customers/ or http://example.com/customers/active/. If that is not desired, just remove the /? in front of the $ i.e.

^(customers)(?:/(active|create))?$

Demo on regex101

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