title: building a PHP router
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4111358/turn-url-route-into-funciton-arguments-php-mvc">turn URL route into funciton arguments php mvc</a><br>
    <a href="https://stackoverflow.com/questions/11770104/cms-routing-in-mvc">CMS Routing in MVC</a>  </p>
  </blockquote>
  
  
  
  <p>I'm currently trying to rewrite a PHP router.</p>
  
  <p>The new htaccess rewrite has the follows.</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine on
      RewriteRule    ^$    public/    [L]
      RewriteRule    (.*) public/index.php?url=$1    [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Whilst in index.php in <code>public</code>, I am getting the URL using the <code>$url = $_GET['url'];</code></p>
  
  <p>What I need to do is to pass <code>$url</code> to the Router function:: <code>route($url)</code></p>
  
  <p>If a URL is passed as : /page/function/$params which would then translate as : <code>index.php?url=page/xapp/function</code>, I'd need to map and route to Controller <code>xapp</code> and call <code>function($params)</code>.</p>
  
  <p>By this time, the autoloader has already been called.  I'd also need to set a default function to be called if only /page/ is called.</p>
  
  <p>How would I achieve this in a router?</p>