Issue
- This article provides a high-level overview of what to expect if the
company.default.home.url
is set as/
.
Environment
- Liferay DXP with sites or instances with multiple virtual hosts
Resolution
- Let's say that your Liferay DXP instance has the following setup:
- Two sites with the following Public Pages Virtual Host
-
Liferay Test 1 with the Public Pages Virtual Host of
liferay-test1.com
-
Liferay Test 2 with the Public Pages Virtual Host of
liferay-test2.com
-
Liferay Test 1 with the Public Pages Virtual Host of
- The
company.default.home.url
property is set as/
(it is set to/web/guest
by default) - Both sites include a Public Page, which contains a Web Content article including a link to
/
as follows:-
<p><a href="/">Test Link</a></p>
-
- Two sites with the following Public Pages Virtual Host
Here's what we should expect:
- When visiting liferay-test1.com and clicking on the respective "Test Link", we will land on http://liferay-test1.com/
- When visiting liferay-test2.com and clicking on the respective "Test Link", we will land on http://liferay-test2.com/
Please bear in mind that this behavior also applies to a theme's ThemeDisplay.getURLHome()
.
One additional note is that the web.server.host
property will affect the host/server resolution logic. When we define a specific hostname in the web.server.host
property, Liferay will enforce this specific hostname to be used when generating URLs. As noted in the default portal.properties, leaving this property blank (i.e., web.server.host=
) will mean that the host is derived from the servlet container. If the web.server.host
property is blank, we should expect the aforementioned behavior where /
will be relative to the hostname in which it was requested.
Additional Information