title: Codeigniter controller in subdirectory not working in virtual host
body: <p>I need help with CodeIgniter -- trying to it to work in virtual host envirnoment in Ampps.</p>
  
  <p>I have been following the following tutorial:
  <a href="http://net.tutsplus.com/tutorials/php/basecamp-style-subdomains-with-codeigniter/" rel="nofollow">http://net.tutsplus.com/tutorials/php/basecamp-style-subdomains-with-codeigniter/</a></p>
  
  <p>I am trying to have two installations of CodeIgniter running in two directories:
  /students and 
  /teachers</p>
  
  <pre><code>www.test.com -&gt; goes to /teachers directory
  
  www.user1.test.com -&gt; goes to /students directory
  </code></pre>
  
  <p>I have the above working on my local machine.  The different URL's take me to the correct directory.  CI works. Problem arises when I try to access controller using redirect.</p>
  
  <p>if I try to <code>redirect('error')</code> I get:</p>
  
  <p>user2.test.com/user2.test.com/error </p>
  
  <p>Also get an "internal server error"</p>
  
  <p>if I type in </p>
  
  <p>user2.test.com/error</p>
  
  <p>I get an "internal server error"</p>
  
  <p>if I type in</p>
  
  <p>user2.test.com/index.php/error</p>
  
  <p>I get desired result</p>
  
  <p>It works if I try to load view directly in </p>
  
  <pre><code>$this-&gt;load-&gt;view('error')
  </code></pre>
  
  <p>I think I need help with the urls and paths.   Any guidance most gratefully received.</p>
  
  <hr>
  
  <p>Nothing particularly enlightening in CI log files</p>
  
  <p>In Apache logs I find:
  Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.</p>
  
  <p>Things I have changed:</p>
  
  <hr>
  
  <p>htaccess in root - changed rewrite base.  Also takes out index.php</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  
  RewriteBase /students/
  
  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>
  
  <hr>
  
  <p><strong>application/config.php</strong></p>
  
  <pre><code>$config['base_url'] = $_SERVER['HTTP_HOST'];
  </code></pre>
  
  <p>As per tutorial.  Needs to be dynamic.</p>
  
  <hr>
  
  <p><strong>my Apache hppd-vhosts.conf file</strong></p>
  
  <pre><code>NameVirtualHost 127.0.0.1:80
  NameVirtualHost *:80
  
  &lt;VirtualHost *:80&gt;
      DocumentRoot "C:/Program Files/Ampps/www/teachers"
      ServerName test.com
      ServerAlias test.com
  
      &lt;Directory "C:/Program Files/Ampps/www/teachers"&gt;
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride All
          Require all granted
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      DocumentRoot "C:/Program Files/Ampps/www/students"
      ServerName test.com
      ServerAlias *.test.com
  
      &lt;Directory "C:/Program Files/Ampps/www/students"&gt;
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride All
          Require all granted
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <hr>
  
  <p>index.php in root</p>
  
  <p>kept as is.  Things got worse when I tried to change these</p>
  
  <pre><code>$system_path = 'system';
  $application_folder = 'application';
  </code></pre>