title: Apache2: internal redirects limit
body: <p>I'm developing a REST interface for an application. The interface interacts with a DB to log some data and perform a bit of statistics. After writing and testing with success my code I performed a bit of refactoring (I wrapped some of the DB interactions on separate functions and called them from the previous code) and then tested again and got this error:</p>
  
  <pre><code>[Wed Dec 02 11:06:46.338128 2015] [core:error] [pid 9649] [client ::1:42760] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
  
  [Wed Dec 02 11:06:46.338139 2015] [core:debug] [pid 9649] core.c(3534): [client ::1:42760] AH00121: r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338147 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338155 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338163 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338170 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338178 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338186 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338193 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338201 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338208 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/rest_functions.php
  [Wed Dec 02 11:06:46.338216 2015] [core:debug] [pid 9649] core.c(3541): [client ::1:42760] AH00122: redirected from r-&gt;uri = /rest/Jobmanager/next
  </code></pre>
  
  <p>My .htacces file (which is still the same which worked with the previous version) is the following:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /rest/JobManager/rest_functions.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>From my (limited) understanding of Apache and PHP working nothing should have changed: I just added a couple of function calls <em>after</em> the rewrite process, so Apache shouldn't see any difference. It is obvious I'm wrong, but I can't see how.</p>
  
  <p>EDIT: It seems the problem is unrelated to my PHP changes, I tested the unrefactored functions and got the same error. Still, the only thing I changed between yesterday (when the code worked) and today is that refactoring...</p>
  
  <p>EDIT 2: I found the problem, somehow a second .htaccess file found its way in the repository and when I pulled this morning it placed itself in the parent directory starting a redirect loop.</p>