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

282
Visualizações
How to rewrite up to 3 optional subolders in the url path as querystring

I have the below generally working (and have seen plenty of examples showing a single subfolder) but I don't know how to adjust the regex for up to 3 optional subfolders, and to exclude any slashes from the query string value

RewriteRule ^([^/]+)/([^/]+)/(.*)?$ player.php?app=$1&stream=$2&mode=$3&%{QUERY_STRING} [L,QSA]

https://wowza.example.com/App/Stream/Mode/?other=stuff
https://wowza.example.com/App/Stream/Mode
https://wowza.example.com/App/Stream/
https://wowza.example.com/App
https://wowza.example.com

This is my perfect output, showing all of the 3 subfolders with or without values in $_GET

Array
(
    [app] => app
    [stream] => stream
    [mode] => 
    [other] => stuff
)

I'm getting either 404, or some variation of this that has the trailing slash.

Array
(
    [app] => app
    [stream] => stream
    [mode] => mode/
    [other] => stuff
)

I can see that the trailing ? after the last capture group makes it optional, but don't understand how to make ALL of them optional and to treat the slashes as delimiters, not "values".

Any assistance is appreciated.

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

0

With no answers, I'll provide what I got working for the query string, though I'm unable to eliminate the trailing slashes. This rewrite rule accounts for 0-3 folders in the path as well as the provided query string.

RewriteRule ^([^/]+)?/?([^/]+)?/?(.+)?$ player.php?app=$1&stream=$2&mode=$3&%{QUERY_STRING} [L,QSA]

Array
(
    [app] => 
    [stream] => 
    [mode] => 
)

Array
(
    [app] => app
    [stream] => stream
    [mode] => mode/
)
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