What webserver are you using?
If Apache, how did you configure ServerName in the VirtualHost sections?
To treat both as distinct websites out of the same instance, set one to be the servername and then alias the other:
Code:
<VirtualHost *:80>
ServerName www.mainsite.com
ServerAlias mainsite.com
...rest of the config...
</VirtualHost>
You may want one URL to be the official name though (e.g.
http://www.mainsite.com with mainsite.com being a redirect to the other)
Set up the official site in one host and create another to do the redirects.
Code:
<VirtualHost *:80>
ServerName http://www.mainsite.com
...rest of the config...
</VirtualHost>
<VirtualHost *:80>
ServerName mainsite.com
Redirect permanent / http://www.mainsite.com/
</VirtualHost>
Duplicate these two hosts for secondary.com.