title: Apache: Virtual Host and URL Rewriting inside httpd.conf for Kohana Framework
body: <p>I'm using the Kohana Framework 3.x. My Webserver is Apache and I use Virtual Hosts, because I manage more than one websites with my Server.</p>
  
  <p>My httpd.conf looks like this:</p>
  
  <pre><code>  &lt;VirtualHost *:80&gt;
   ServerName www.myPage1.com
   ServerAlias myPage1.com
   DocumentRoot /var/www/myPage1
  &lt;/VirtualHost&gt;
  &lt;VirtualHost *:80&gt;
   ServerName www.myPage2.com
   ServerAlias myPage2.de
   DocumentRoot /var/www/myPage2
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>In Kohana every http request needs to go to the index.php first. Because I dont like these ugly URLs that all starts with index.php (for example www.myPage1.com/index.php/item/detail/itemId) I used the following .htaccess file which worked perfectly</p>
  
  <pre><code># Turn on URL rewriting
  RewriteEngine On
  
  # Installation directory
  RewriteBase /
  
  # Protect hidden files from being viewed
  &lt;Files .*&gt;
      Order Deny,Allow
      Deny From All
  &lt;/Files&gt;
  
  # Protect application and system files from being viewed
  RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
  
  # Allow any files or directories that exist to be displayed directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # Rewrite all other URLs to index.php/URL
  RewriteRule .* index.php/$0 [PT]
  </code></pre>
  
  <p>I would now like to not use a .htaccess file anymore and instead put all the rewrite logic into my httpd.conf file. The following gives me a "400 Bad Request"</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
   RewriteEngine On
   &lt;Files .*&gt;
    Order Deny,Allow
    Deny From All
   &lt;/Files&gt;
   RewriteRule ^(?:aplication|modules|system)\b.* index.php/$0 [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule .* index.php/$0 [PT]
  
   ServerName www.myPage2.com
   ServerAlias myPage2.com
   DocumentRoot /var/www/myPage2
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>What am I doing wrong? Help would be appreciated!</p>