title: Internal URL rewrite no longer working after upgrading Apache to 2.4
body: <p>I need to internally rewrite the base URL so that instead of / being mapped to /index.php (default behaviour) it goes to another script named contents.php. I have a simple .htaccess in the doc root:</p>
  
  <pre><code>RewriteEngine on
  RewriteRule ^/?$ /contents.php?id_cat=0 [L]
  </code></pre>
  
  <p>That was working fine with Apache 2.2 and no longer works with Apache 2.4.6. Now it is simply ignored and the /index.php script ends up being called by default.</p>
  
  <p>However, if I add the Relocate flag:</p>
  
  <pre><code>RewriteEngine on
  RewriteRule ^/?$ /contents.php?id_cat=0 [R,L]
  </code></pre>
  
  <p>... it does work, but it exposes the rewritten URL, which I don't want. </p>
  
  <p>I tried using the PT (passthrough) flag <code>[PT,L]</code> and <code>[END]</code> but no luck.</p>
  
  <p>What am I missing?</p>
  
  <p><strong>EDIT:</strong> I enabled trace logging for rewrite and this is what I got for a <em>single</em> request:</p>
  
  <pre><code>[Sat Nov 16 17:43:22.021036 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b67b0a0/initial] [perdir /var/www/bacityapartments/] strip per-dir prefix: /var/www/bacityapartments/
  -&gt;
  [Sat Nov 16 17:43:22.021075 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b67b0a0/initial] [perdir /var/www/bacityapartments/] applying pattern '^/?$' to uri ''
  [Sat Nov 16 17:43:22.021087 2013] [rewrite:trace2] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b67b0a0/initial] [perdir /var/www/bacityapartments/] rewrite '' -&gt; '/contents.php?id_cat=0'
  [Sat Nov 16 17:43:22.021096 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b67b0a0/initial] split uri=/contents.php?id_cat=0 -&gt; uri=/contents.php, args=id_cat=0
  [Sat Nov 16 17:43:22.021111 2013] [rewrite:trace1] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b67b0a0/initial] [perdir /var/www/bacityapartments/] internal redirect with /contents.php [INTERNAL REDIRECT]
  [Sat Nov 16 17:43:22.021197 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6790a0/subreq] [perdir /var/www/bacityapartments/] strip per-dir prefix: /var/www/bacityapartments/in
  dex.html -&gt; index.html
  [Sat Nov 16 17:43:22.021208 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6790a0/subreq] [perdir /var/www/bacityapartments/] applying pattern '^/?$' to uri 'index.html'
  [Sat Nov 16 17:43:22.021218 2013] [rewrite:trace1] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6790a0/subreq] [perdir /var/www/bacityapartments/] pass through /var/www/bacityapartments/index.html
  [Sat Nov 16 17:43:22.021268 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6740a0/subreq] [perdir /var/www/bacityapartments/] strip per-dir prefix: /var/www/bacityapartments/in
  dex.cgi -&gt; index.cgi
  [Sat Nov 16 17:43:22.021290 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6740a0/subreq] [perdir /var/www/bacityapartments/] applying pattern '^/?$' to uri 'index.cgi'
  [Sat Nov 16 17:43:22.021299 2013] [rewrite:trace1] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6740a0/subreq] [perdir /var/www/bacityapartments/] pass through /var/www/bacityapartments/index.cgi
  [Sat Nov 16 17:43:22.021345 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6790a0/subreq] [perdir /var/www/bacityapartments/] strip per-dir prefix: /var/www/bacityapartments/in
  dex.pl -&gt; index.pl
  [Sat Nov 16 17:43:22.021355 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6790a0/subreq] [perdir /var/www/bacityapartments/] applying pattern '^/?$' to uri 'index.pl'
  [Sat Nov 16 17:43:22.021364 2013] [rewrite:trace1] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6790a0/subreq] [perdir /var/www/bacityapartments/] pass through /var/www/bacityapartments/index.pl
  [Sat Nov 16 17:43:22.021389 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6740a0/subreq] [perdir /var/www/bacityapartments/] strip per-dir prefix: /var/www/bacityapartments/in
  dex.php -&gt; index.php
  [Sat Nov 16 17:43:22.021398 2013] [rewrite:trace3] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6740a0/subreq] [perdir /var/www/bacityapartments/] applying pattern '^/?$' to uri 'index.php'
  [Sat Nov 16 17:43:22.021407 2013] [rewrite:trace1] [pid 5895] mod_rewrite.c(468): [client 127.0.0.1:55297] 127.0.0.1 - - [bacityapartments.localhost/sid#7f7e3b748400][rid#7f7e3b6740a0/subreq] [perdir /var/www/bacityapartments/] pass through /var/www/bacityapartments/index.php
  00
  </code></pre>
  
  <p>So the rewriting is being performed, but then it goes on just as if it didn't.</p>
  
  <p><strong>EDIT 2:</strong> If I move this rules to the virtualhost configuration file, it does work as expected. More information can be found <a href="https://stackoverflow.com/questions/17095981/why-apache-mod-rewrite-rewrites-twice-my-url?rq=1">here</a>.</p>
  
  <p>Also, this problem only happens for the directory itself. For instance, if I rewrite <code>/hello</code> to <code>/contents.php?msg=hello</code>, it works fine from .htaccess too.</p>