How to change site URL prefix from /web/sitename to a custom one

Issue

  • Our Liferay web site has the following URL prefix: /web/sitename and its URLs are: http://example.com/web/sitename/mypage
  • We want to change the URL prefix to: /level1/level2/level3 so its URLs are changed to: http://example.com/level1/level2/level3/mypage
  • How can we change it?

Environment

  • Liferay DXP 7.2
  • Liferay DXP 7.3

Resolution

To change your current site URL prefix: /web/sitename to a custom one (for example /level1/level2/level3) there are two steps:

  1. Remove the /web/sitename prefix
  2. Add the custom /level1/level2/level3 prefix

Removing the /web/sitename prefix of a site

As one Liferay can store several sites, the URL prefix /web/sitename is used by Liferay to find in which site you are currently located.

If you want to remove it, you can use a virtual host name at site level, and access to the site using this virtual host.

For more information see How to remove unnecessary parts from the URL / shorten URL / make URL friendlier article.

 

Adding a custom prefix to the URL site

If you want to add a custom prefix /level1/level2/level3 prefix, it is not possible to configure this at site level.

As a workaround you can edit the friendly urls of every site page and add the custom prefix to all of them, so you will end having:

  • Page 1: /level1/level2/level3/page1
  • Page 2: /level1/level2/level3/page2
  • Page 3: /level1/level2/level3/page3
  • etc.

 

You can change the friendly URL of a page from its configuration page

 

这篇文章有帮助吗?
0 人中有 0 人觉得有帮助