Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!