title: Modify the MY_Router.php file for QUERY STRING Codeigniter 3.0.6
body: <p>I use codeigniter 3.0.6 query string like</p>
  
  <pre><code>index.php?d=directoryt&amp;c=controller
  index.php?d=directory&amp;c=controller&amp;m=function
  </code></pre>
  
  <p>How ever having two get methods for directory and controller is a bit long.</p>
  
  <blockquote>
    <p><strong>Question</strong> Is there any way to modify the <code>protected function
    _set_routing()</code> function using a MY_Router.php to get it so it will pick up the directory and controller by using one query only like example below.</p>
  </blockquote>
  
  <pre><code>index.php?route=directory/controller
  // If need to get function 
  index.php?route=directory/controller&amp;m=function
  </code></pre>
  
  <p>What have tried so far</p>
  
  <pre><code>&lt;?php
  
  class MY_Router extends CI_Router {
  
      protected function _set_routing()
      {
          // Load the routes.php file. It would be great if we could
          // skip this for enable_query_strings = TRUE, but then
          // default_controller would be empty ...
          if (file_exists(APPPATH.'config/routes.php'))
          {
              include(APPPATH.'config/routes.php');
          }
  
          if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
          {
              include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
          }
  
          // Validate &amp; get reserved routes
          if (isset($route) &amp;&amp; is_array($route))
          {
              isset($route['default_controller']) &amp;&amp; $this-&gt;default_controller = $route['default_controller'];
              isset($route['translate_uri_dashes']) &amp;&amp; $this-&gt;translate_uri_dashes = $route['translate_uri_dashes'];
              unset($route['default_controller'], $route['translate_uri_dashes']);
              $this-&gt;routes = $route;
          }
  
          // Are query strings enabled in the config file? Normally CI doesn't utilize query strings
          // since URI segments are more search-engine friendly, but they can optionally be used.
          // If this feature is enabled, we will gather the directory/class/method a little differently
          if ($this-&gt;enable_query_strings)
          {
              // If the directory is set at this time, it means an override exists, so skip the checks
  
              if ( ! isset($this-&gt;directory))
              {
                  $_route = isset($_GET['route']) ? trim($_GET['route'], " \t\n\r\0\x0B/") : '';
  
                  if ($_route !== '')
                  {
                      echo $_route;
  
                      $this-&gt;uri-&gt;filter_uri($_route);
                      $this-&gt;set_directory($_route);
                  }
              }
  
  
  
              // Routing rules don't apply to query strings and we don't need to detect
              // directories, so we're done here
              return;
          }
  
          // Is there anything to parse?
          if ($this-&gt;uri-&gt;uri_string !== '')
          {
              $this-&gt;_parse_routes();
          }
          else
          {
              $this-&gt;_set_default_controller();
          }
      }
  }
  </code></pre>
  
  <p>config.php</p>
  
  <pre><code>$config['allow_get_array'] = TRUE;
  $config['enable_query_strings'] = TRUE;
  $config['controller_trigger'] = 'c';
  $config['function_trigger'] = 'm';
  $config['directory_trigger'] = 'd';
  
  // Modifyed in MY_Router.php
  $config['route'] = 'route';
  </code></pre>