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

134
Visualizações
Apache RewriteRule executing twice

I have a quite simple need : to redirect any request to a single file.

So I put, at my apache directory root, a .htaccess :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^ index.php?q=test [L,QSA]
</IfModule>

All the requests are indeed redirected to index.php but a wierd thing appears : the PHP $_SERVER['QUERY_STRING'] contains q=test&q=test showing that the redirection occurs twice (and the REDIRECT_URL doesn't contains index.php but the passed URL leading to it being equal to REQUEST_URI.

How can I fix that, considering that I have only .htaccess way to configure Apache ?

Testing :

  • Create a folder at your apache web root (ex: redirect/)
  • add a .htaccess file containing the code above
  • add a index.php file dumping $_SERVER to see the result
  • try any URL (ex: redirect/foo/bar) and you should see the dump.

Apache version : 2.4.33 ; PHP version : 7.2.4 (& 5.6.35) ; WAMP (Win) & Red Hat (Linux).

over 4 years ago · Santiago Trujillo
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