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

244
Visualizações
Rewrite URL that matches a directory, has a specific HTTP query and does NOT have a specific HTTP query combination

I've come across plenty of questions dealing with redirecting based on HTTP queries and of course matching partial parts of URLs however not both.

My directory structure looks like the following:

  • http://localhost/common_parent/.htaccess
  • http://localhost/common_parent/demo/themes/
  • http://localhost/common_parent/themes/?ajax=1

The rewrite that I have works fine except it blocks the directory in the second list item:

RewriteCond %{REQUEST_URI} !\.xml$
RewriteRule ^[^/].*/themes(.+) themes$1 [L]

Unfortunately both demo/themes/?ajax=1 and themes/?ajax=1 are both requested with the ajax HTTP query. However only the demo/themes/ is requested with a foo HTTP query.

  • http://localhost/common_parent/demo/themes/?ajax=1&foo=bar
  • http://localhost/common_parent/themes/?ajax=1

So in short how do I rewrite my rewrite to only apply if the ajax http query is present and simultaneously the foo http query is not present?

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

0

You can use rewrite rule like this:

# when ajax=<whatever> query parameter is present
RewriteCond %{QUERY_STRING} (?:^|&)ajax= [NC]
# when foo=<whatver> is not present
RewriteCond %{QUERY_STRING} !(?:^|&)foo= [NC]
# when URI is not ending with .xml
RewriteCond %{REQUEST_URI} !\.xml$ [NC]
# rewrite handler
RewriteRule ^[^/].*/themes(.+) themes$1 [L]
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