title: Apache RewriteEngine - Rewrite anything that not exists to index.php
body: <p>I'm really struggling now.<br>First of all, i searched on Google and here, and none of the solutions found worked for me. I don't really have much time right now to completely dig into Apache docs for solid understanding of the RewriteEngine(will do later for sure).</p>
  
  <p><strong>WHAT I NEED</strong><br>
  I need to handle special requests from our Google Adwords campaign, which look like this: <a href="http://website.com/something/%first_param%/%second_param%/%third_param%" rel="nofollow noreferrer">http://website.com/something/%first_param%/%second_param%/%third_param%</a>
  In my document root directory, i have <em>index.php</em> where i parse the query string using regex and acquire these parameters, like this:<br>
  <code>$request_URI = $_SERVER['REQUEST_URI'];</code>
  <code>preg_match('/\/[^\/]+\/([^\/]+)\/([^\/]+)\/([^\/]+)/', $request_URI, $matches);</code><br><br>
  <strong>THE PROBLEM</strong><br>
  Apache successfully redirects everything, but it also includes all additional requests for all the resources, so instead of fetching resources it just gets me the same index.php.<br><br>
  Currently i have this <em>.htaccess</em> file in my document root:<br>
          <code>RewriteEngine on</code><br>
          <code>RewriteCond %{REQUEST_FILENAME} !-d</code><br>
          <code>RewriteCond %{REQUEST_FILENAME} !-f</code><br>
          <code>RewriteRule .* index.php?url=$0 [QSA,L]</code><br><br>
  Please note, that i am using Virtual Host for this project:<br>
  <code>&lt;VirtualHost *:80&gt;</code><br>
      <code>ServerName masuma.hyperauto.local</code><br>
      <code>DocumentRoot "c:/wamp64/www/projects/masuma landing"</code><br>
  <code>&lt;/VirtualHost&gt;</code><br>
  I have my <em>index.php</em> in this root directory above.<br><br>
  I have also enabled RewriteEngine logs and found interesting things here, but i still can't solve this:</p>
  
  <pre><code>add path info postfix: C:/wamp64/www/projects/masuma landing/test -&gt; C:/wamp64/www/projects/masuma landing/test/test/firm/css/bootstrap.min.css, referer: host_here/test/test/firm/toyota
  strip per-dir prefix: C:/wamp64/www/projects/masuma landing/test/test/firm/css/bootstrap.min.css -&gt; test/test/firm/css/bootstrap.min.css, referer: host_here/test/test/firm/toyota
  applying pattern '.*' to uri 'test/test/firm/css/bootstrap.min.css', referer: host_here/test/test/firm/toyota
  rewrite 'test/test/firm/css/bootstrap.min.css' -&gt; 'index.php?url=test/test/firm/css/bootstrap.min.css', referer: host_here/test/test/firm/toyota
  split uri=index.php?url=test/test/firm/css/bootstrap.min.css -&gt; uri=index.php, args=url=test/test/firm/css/bootstrap.min.css, referer: host_here/test/test/firm/toyota &lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>I can see here, that it prepends the path in query string to the resource filename, like <em>test/test/firm/css/bootstrap.min.css</em>, but the resources are in the document root!<br><br>
  <strong>UPD: SOLUTION</strong><br>
  The flag <code>[DPI]</code> in my <code>RewriteRule</code> solved the problem.<br>
  Now the rule looks like <code>RewriteRule .* index.php?url=$0 [QSA,L,DPI]</code><br>
  And, what is important, i am still able to get the original query path in <code>$_SERVER['REQUEST_URI']</code></p>