title: what are the pros and cons of setting virtual host in Liferay?
body: <p>I am using multiple domains to access liferay portal instance.</p>
  <p>For example following are the domains mapped in hosts file of windows:</p>
  <ol>
  <li><code>www.liferaytest1.com</code></li>
  <li><code>www.liferaytest2.com</code></li>
  </ol>
  <p>and in Liferay's <kbd>Control Panel</kbd> → <kbd>Portal Settings</kbd>, <code>www.liferaytest1.com</code> is set as virtual host.</p>
  <p>I can access portal instance with all above mention domains along with <code>localhost</code>.</p>
  <p>When I access portal with <code>www.liferaytest1.com</code> then I can access <code>Guest</code> site pages directly. Say, <code>home</code> is a page in <code>Guest</code> site then instead of accessing with <code>www.liferatest1.com/web/guest/home</code> I can access it directly with <code>www.liferaytest1.com/home</code></p>
  <p>So URL is shortened to some extend.<br />
  So far so good.</p>
  <h3>First Concern</h3>
  <p>Now when I try to access portal via <code>www.liferaytest2.com</code> and when I click any sites listed in <code>My Sites</code> portlet of Liferay, it redirects me to that site with the domain mentioned in virtual host i.e. <code>www.liferaytest1.com</code> instead of retaining <code>www.liferaytest2.com</code>.</p>
  <p>Suppose I have a Site named <code>Help</code>, so when I click on help site link in <code>My Sites</code> portlet then instead of staying with <code>www.liferaytest2.com</code> domain it redirects me with <code>www.liferaytest1.com</code> domain.</p>
  <p>This is due to virtual host mapping done in liferay.</p>
  <h3>Second Concern</h3>
  <p>When I am accessing the portal with <code>www.liferaytest2.com</code> and subscribe to any of the Assets then the links in email contain the virtual host domain i.e <code>www.liferaytest1.com</code>.</p>
  <hr />
  <p><em><strong>How to overcome above mention issues?</strong></em></p>
  <p>My requirement is to stay relative to the portal accessing domain.<br />
  When I access portal via <code>www.liferaytest2.com</code> then it should not redirect me to <code>www.liferaytest1.com</code> on-click of any of the Site-links as explained above and also emails that I would be getting should also be relative to the domain I am accessing i.e. <code>www.liferaytest2.com</code>.</p>