title: .htaccess with virtual hosts
body: <p>I decided to add virtual hosts on apache. My previous conf was:</p>
  
  <p><code>&lt;VirtualHost *:80&gt;
   ServerName domain1.com
   DocumentRoot /var/www/
  &lt;/VirtualHost&gt;</code></p>
  
  <p>I have .htaccess in /var/www/ which was doing redirect for non-www to www and subdomain like forum.domain1.com to www.domain1.com/forum
  This is my htaccess file:</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{HTTP_HOST} ^forum\.domain1\.com$
  RewriteRule ^ http://www.domain1.com/forum%{REQUEST_URI} [P]
  RewriteCond %{HTTP_HOST} !^www..*
  RewriteCond %{HTTP_HOST} !^$
  RewriteCond %{HTTP_HOST} ^([^.]*).(com|com/)
  RewriteRule ^.*$ http://www.%1.%2{REQUEST_URI} [R=301,L]
  </code></pre>
  
  <p>Now i have two domains and i setup virtual hosts using this tutorial:
  <a href="https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts" rel="nofollow">Virtual host on ubuntu</a></p>
  
  <p>So, now in my /etc/apache2/sites-available i have 3 files, default, domain1.com and domain2.com. .htaccess stayed in /var/www/ and its working for domain1.com but it is not working for domain2.com.
  Do i need to change .htaccess in /var/www/ to accept domain2 or i can add .htaccess to /var/www/domain2.com/public_html/ ? 
  Do i need to move previous .htaccess from /var/www/ to /var/www/domain1.com/public_html?
  Thanks in advance!</p>