title: Single-entry implementation gone wrong
body: <p>I'm doing my first single-entry site and based on the result, I can't see the benefit.</p>
  
  <p>I've implemented the following:</p>
  
  <ul>
  <li>.htaccess redirects all requests to index.php at the root</li>
  <li>Url is parsed and each /segment/ is stored as an element in an array</li>
  <li>First segment indicates which folder to include (e.g. "users" » "/pages/users/index.php").</li>
  <li>index.php file of each folder parses the remaining elements in the segments array until array is empty.</li>
  <li>content.php file of each folder is included if there are no more elements in the segments array, indicating that the destination file is reached</li>
  </ul>
  
  <p><strong>Sample</strong></p>
  
  <p>File structure ( folders in [] ):</p>
  
  <ul>
  <li><em>[root]</em>
  <ul>
  <li>index.php</li>
  <li><em>[pages]</em>
  <ul>
  <li><em>[users]</em>
  <ul>
  <li>index.php</li>
  <li>content.php</li>
  <li><em>[profile]</em>
  <ul>
  <li>index.php</li>
  <li>content.php</li>
  <li><em>[edit]</em>
  <ul>
  <li>index.php</li>
  <li>content.php</li>
  </ul></li>
  </ul></li>
  </ul></li>
  <li><em>[other-page]</em>
  <ul>
  <li>index.php</li>
  <li>content.php</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>Request: <strong>http://mysite.com/users/profile/</strong></p>
  
  <ol>
  <li><p>.htaccess redirects request to <a href="http://mysite.com/index.php" rel="nofollow">http://mysite.com/index.php</a></p></li>
  <li><p>URL is parsed and segments array contains: [1] users, [2] profile</p></li>
  <li><p>index.php maps [1] to "pages/users/index.php", so includes that file</p></li>
  <li><p>pages/users/index.php maps [2] to pages/users/profile/index.php, so includes that file</p></li>
  <li><p>Since no other elements in the segments array, the contents.php file in the current folder (pages/users/profile) is included.</p></li>
  </ol>
  
  <hr>
  
  <p>I'm not really seeing the benefit of doing this over having functions that include components of the site (e.g. include_header(), include_footer(), etc.), so I conclude that I'm doing something terribly wrong. I'm just not sure what it is.</p>