ナレッジベース
公開されました Oct. 9, 2025

Disabling localization - I cannot remove the locale from the page URL - DXP 7.3

written-by

Ahmed Abdin

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

We have a website set with the English language only. The pages of the site can be accessed with two URLs. For example:

www.liferay.com/en/customer

www.liferay.com/customer

We added the property locale.prepend.friendly.url.style=0 to the portal-ext.properties file. However, the locale /en can still be added manually to the URL.

Environment

  • Liferay DXP 7.1
  • Liferay DXP 7.2
  • Liferay DXP 7.3

Resolution

The described behavior is intended: The page can either be reached by its friendly URL or with the localized URL, and it cannot be changed within the scope of Support as many users are relying on this functionality. However, there is a workaround that can be helpful:

According to the information of this property:

#
  # Set this to 0 if the locale is not automatically prepended to a URL. This
  # means that each URL could potentially point to many different languages.
  # For example, the URL http://localhost:8080/web/guest/home could then be
  # viewed by users in many different languages.
  #
  # Set this to 1 if the locale is automatically prepended to a URL when the
  # requested locale is not the default locale. This means that each URL
  # points to just one language. For example, the URL
  # http://localhost:8080/web/guest/home would point to the default language.
  # The URL http://localhost:8080/zh/web/guest/home and
  # http://localhost:8080/zh_CN/web/guest/home would both point to the Chinese
  # language.
  #
  # In cases where the prepended locale is "zh" and not the complete locale
  # "zh_CN", then the full locale returned will be based on the order in which
  # the locales appear in the property "locales". If "zh_CN" appears before
  # "zh_TW", then "zh" will be a short hand for "zh_TW".
  #
  # The default language is set in system.properties with the properties
  # "user.country" and "user.language".
  #
  # Set this to 2 if the locale is automatically prepended to every URL. This
  # means that each URL points to just one language.
  #
  # Set this to 3 if the locale is automatically prepended to a URL when the
  # requested locale is not the default user locale. In the case of guest
  # users, the behavior is the same as having a value of 1.
  #
 # Note that each language requires an entry in the property "locales" and a

 # servlet mapping in web.xml for the I18n Servlet.
In the last note: 

Note that each language requires an entry in the property "locales" and a servlet mapping in web.xml for the I18n Servlet.

You can check that web.xml from within the bundle: "liferayhome\tomcatversion\webapps\ROOT\WEB-INF\

Comment the related servlet-mapping part with the locale /en/:
<servelet-mapping>
     <servlet-name>I18n Servlet</servlet-name>
     <url-pattern>/en/*</url-pattern>
</servlet-mapping>
Start the bundle, and the locale /en is disabled. So even if we manually add the /en to the URL we will not access the page.

Please note that this workaround is only a tip and implementing this solution is at your own discretion as it falls under customization, and our support is not compatible with customization issues. This workaround should be tested in a Test environment by a developer who is specialized in customization in order to make sure that it will not cause further issues. 

 

You can implement a custom hook to achieve this, or create a rewrite rule in the webserver that can remove the /en from the URL.

If you require further assistance with the customization we recommend contacting our Global Services Team. Please refer to your Sales Representative for more information.

did-this-article-resolve-your-issue

ナレッジベース