title: best way to process unlimited subfloders via query string (php)
body: <p>I have written a php script which loads content dynamically. I mean: when you visit mydomain.com/example , it gets rewritten by htaccess (the real url would be something like mydomain.com/index.php?example) and loads content based in the query string. </p>
  
  <pre><code>$page = $_SERVER['QUERY_STRING'];
  if (file_exists("pages/".$page.".txt") ) {
  load the file and so on
  }
  </code></pre>
  
  <p>But what would be the best solution to support sub-folders as well? So that you can enter mydomain.com/example/test/test2 and get the content from pages/example/test/test2? I guess this should be included in the query string, but rewritten using .htaccess.
  At the moment, my htaccess looks like this:</p>
  
  <pre><code>RewriteEngine On 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*) index.php?/$1 [L]
  </code></pre>