title: Cannot restrict direct access to views and functions in Codeigniter using basepath
body: <p>I want to stop direct access to controller functions or views in Codeigniter for that i am using following code, I have seen other similar links on stackoverflow but they are not working, i am able to load the view by hitting url:</p>
  
  <blockquote>
    <p>Controller: abc.php</p>
  </blockquote>
  
  <pre><code>&lt;?php 
  
  if (!defined('BASEPATH')) exit('No direct script access allowed');
  
  Class Abc extends CI_Controller {
  
    public function __construct() {
       parent::__construct();
    }
  
    public function Create_Course() {
       $this-&gt;load-&gt;view('abc');
    }
  }
  
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>View: abc.php</p>
  </blockquote>
  
  <pre><code>&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;ABC&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;Whatever&lt;/h1&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>