title: how to give complete controller's path in codeigniter
body: <p>I have a variable in javascript as follows which works fine.</p>
  
  <pre><code>var url = http://example.com/directory_name/
  </code></pre>
  
  <p>above link returns json data which I later on display it using javascript.
  But what I want is to give a complete path to a controller and then name of the function like following</p>
  
  <pre><code>http://example.com/directory_name/api/v1/ //whereas api is controller's name and v1 function inside this controller
  </code></pre>
  
  <p>how can I achieve this?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is my code for controller</p>
  
  <pre><code>class Api extends CI_Controller {
  public function index() {
      //$this-&gt;load-&gt;view('api');
      $this-&gt;v1('api');
  }
  
  public function v1 () {
      //$this-&gt;load-&gt;view('api');
      echo site_url();
      $arr = array(
        array(
          'id' =&gt; 15642,
          'title' =&gt; 'title one',
          'description' =&gt; 'this is description for title one'
        ),
        array(
          'id' =&gt; 15643,
          'title' =&gt; 'title two',
          'description' =&gt; 'this is description for title two'
        ),
        array(
          'id' =&gt; 15644,
          'title' =&gt; 'title Three',
          'description' =&gt; 'this is description for title Three. this is description for title Three. this is description for title Three.'
        )
      );
  
      echo json_encode($arr);
  }
  }
  </code></pre>
  
  <p><strong>Update 2</strong></p>
  
  <p>Here is JS</p>
  
  <pre><code>init: function (jokesContainer) {
              container = container;
              url       = 'http://example.com/directory/api/v1';    
              Get.get(url, container);
          }
  </code></pre>
  
  <p><strong>Update 3</strong></p>
  
  <p>.htaccess file</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase chrome_web_apps
  
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ index.php?/$1 [L]
  
  RewriteCond %{REQUEST_URI} ^application.*
  RewriteRule ^(.*)$ index.php?/$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
  &lt;/IfModule&gt;
  
  &lt;IfModule !mod_rewrite.c&gt;
  ErrorDocument 404 /index.php
  &lt;/IfModule&gt;
  </code></pre>