I decided to add virtual hosts on apache. My previous conf was:
<VirtualHost *:80>
ServerName domain1.com
DocumentRoot /var/www/
</VirtualHost>
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:
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]
Now i have two domains and i setup virtual hosts using this tutorial: Virtual host on ubuntu
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!