title: Simple PHP routing
body: <p>I am setting up a simple routing system for my new custom MVC framework that I am making.</p>
  
  <p>Currently my router class views the URL as such:</p>
  
  <pre><code>www.example.com/controller/controller_action/some/other/params
  </code></pre>
  
  <p>So, essentially...I've been reserving the first two segments of the URI for controller routing. However, what if I just want to run the following?</p>
  
  <pre><code>www.example.com/controller/some/other/params
  </code></pre>
  
  <p>...which would attempt to just run the default controller action and send the extra parameters to it?</p>
  
  <p>Here is the simple router I'm using:</p>
  
  <pre><code>    \* --- htaccess --- *\
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
  
      \* --- index.php --- *\
      if (array_key_exists('rt',$_GET)) {
          $path = $_GET['rt'];
          $uri = explode('/',$this-&gt;path);
          if(empty($uri[0])) {
              $load-&gt;ctrl('home');
          }
          elseif(empty($uri[1])) {
              $load-&gt;ctrl($uri[0]);
          }
          else {
              $load-&gt;ctrl($uri[0],$uri[1]);
          }
      }
      else {
          $load-&gt;ctrl('index');
      }
  
      \* --- loader class --- *\
      public function ctrl($ctrl,$action=null) {
          $ctrl_name = 'Ctrl_'.ucfirst(strtolower($ctrl));
          $ctrl_path = ABS_PATH . 'ctrl/' . strtolower($ctrl) . '.php';
          if(file_exists($ctrl_path)) { require_once $ctrl_path;}
  
          $ctrl = new $ctrl_name();
  
          is_null($action) ? $action = "__default" : $action = strtolower($action);
          $ctrl-&gt;$action();
      }
  </code></pre>
  
  <p>How can I do this?</p>