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

283
Vistas
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 Respuestas
Responde la pregunta

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 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