Managing Site URLs

Configuring Virtual Hosts Site URLs

A virtual host connects a domain name (e.g., www.helloworld.com) to a site. This can be a full domain or a subdomain (e.g., developers.helloworld.com). You can use this to host many websites as separate sites on one Liferay DXP server.

  1. With your provider, set the DNS name to point to your Liferay DXP instance’s IP address. You can refer to a guide from a common provider on how to assign a domain as an example.

  2. Inside Liferay DXP, open the Site Menu (Site Menu), expand Configuration, and go to Site SettingsSite ConfigurationSite URL.

    Under Site Configuration, go to Site URL.

  3. Enter the desired domain or subdomain in the Virtual Host field (e.g., www.helloworld.com, developers.helloworld.com).

    The Virtual Host field and Language drop-down appear side by side; the Language drop-down defaults to Default Language.

    Important

    A domain can only be applied to a single site. You can’t map a single domain to multiple sites.

  4. Click Save.

Your site is now accessible using the configured domain.

Assigning Languages to Virtual Hosts

If your site is available in multiple languages and each language has its own domain, you can map each domain to a specific language. Liferay uses these mappings when generating alternate URLs for multilingual SEO (see Alternate URLs and Localized Virtual Hosts).

  1. Open the Site Menu (Site Menu), expand Configuration, and go to Site SettingsSite ConfigurationSite URL.

  2. Click Add (Plus Button) to add a new virtual host row.

  3. Enter the domain for the language in the Virtual Host field (for example, www.holamundo.com).

    Note

    The Language drop-down shows only languages configured for the site. If no language is specified, the site’s default language is used.

  4. Select the language from the Language drop-down (for example, Spanish (Spain)).

  5. Repeat for each additional language.

    Three virtual host rows, each mapped to a different language: Default Language, Spanish (Spain), and German (Germany).

  6. Click Save.

After saving, the virtual host rows remain visible under Site URL, showing each domain and its assigned language.

Alternate URLs and Localized Virtual Hosts

When you assign a language to a virtual host, Liferay uses those localized virtual hosts when generating alternate URLs for multilingual SEO. Alternate URLs are the language-specific links (hreflang tags) that tell search engines which domain hosts each language variant of your site, helping them show the right language to the right audience.

For each locale (a language and regional variant, for example, Spanish (Spain)), Liferay resolves the alternate URL in this order:

  1. If the page has a custom canonical URL (a page-specific preferred address for SEO) configured for that locale, it is used.
  2. If a virtual host is configured for that locale, Liferay uses its domain.
  3. If no localized virtual host exists for the locale, Liferay uses the site’s default virtual host.

For example, if your site’s default virtual host is www.example.com and you’ve mapped de.example.com to German, alternate URLs for German pages use de.example.com. Locales without a dedicated virtual host fall back to www.example.com.