title: Codeigniter subdomain routing
body: <p>I'm trying to setup a blog script on a website running on the CodeIgniter framework. I want do this without making any major code changes to my existing website's code. I figured that creating a sub domain pointing to another Controller would be the cleanest method of doing this.</p>
  
  <p>The steps that I took to setup my new <code>Blog</code> controller involved:</p>
  
  <ol>
  <li>Creating an A record pointing to my server's ip address.</li>
  <li>Adding new rules to CodeIgniter's <code>routes.php</code> file.</li>
  </ol>
  
  <p>Here is what I came up with:</p>
  
  <pre><code>switch ($_SERVER['HTTP_HOST']) {
      case 'blog.notedu.mp':
          $route['default_controller'] = "blog"; 
          $route['latest'] = "blog/latest";
          break;
      default:
          $route['default_controller'] = "main";
          break;
  }
  </code></pre>
  
  <p>This should point <code>blog.notedu.mp</code> and <code>blog.notedu.mp/latest</code> to my <code>blog</code> controller.</p>
  
  <p>Now here is the problem...</p>
  
  <p>Accessing <code>blog.notedu.mp</code> or <code>blog.notedu.mp/index.php/blog/latest</code> works fine, however accessing <code>blog.notedu.mp/latest</code> takes me to a 404 page for some reason...</p>
  
  <p>My .htaccess file looks like this (the default for removing index.php from the url): </p>
  
  <pre><code>RewriteEngine on
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ /index.php/$1 [L]
  </code></pre>
  
  <p>And my <code>Blog</code> controller contains the following code:</p>
  
  <p>
  
  <pre><code>class Blog extends CI_Controller {
  
      public function _remap($method){
          echo "_remap function called.\n";
          echo "The method called was: ".$method;
      }
  
      public function index()
      {
          $this-&gt;load-&gt;helper('url');
          $this-&gt;load-&gt;helper('../../global/helpers/base');
  
          $this-&gt;load-&gt;view('blog');
      }
  
      public function latest(){
          echo "latest working";
      }
  
  }
  </code></pre>
  
  <p>What am I missing out on or doing wrong here? I've been searching for a solution to this problem for days :( </p>