I have two versions of applications running on an apache server.Now I have to point one to the main domain viz www.example.com
and the other to a subdomain
mysite.example.com
.
The challenge I am facing is if I type in only example.com
it goes to mysite.example.com
instead of www.example.com
.
I do not have anything configured in the .htaccess
files as far as redirection is concerned. Also DNS entries for both www
and example.com
are pointing to the same ip
My conf files are as below:
This is for the subdomain
ServerName mysite.example.com
#ServerAlias mysite.example.com // not sure if i need alias
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/site1
<Directory /var/www/html/site1>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
This one for the main domain
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/site2
<Directory /var/www/html/site2>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I want to serve one version for the subdomain and the other on the main domain,with all URL possibilities covered.
Can anybody point where I am going wrong on this?