Liferay : leader dans le Magic Quadrant du Gartner pour la 6ème année consécutive! Découvrez le rapport
« Retour - FrontPage

Changing context path of portal

This article describes the issues related to migration of your Liferay portal to another context path. What context path means? In one sentence, the context path is the name after slash, by which your application is accessible. If your server is running under and you want to make it accessible under, this article is definitelly for you!. If you ever have been developing some web application, then the term context path should be well-known for you. Anyways, let's start with a short description. If you are familiar with this term, just skip the first chapter.

Well, usually if you deploy your portal to your Application Server, or Servlet Container as Apache Tomcat, your Liferay portal runs under ROOT Context path, meaning it is available under <your_ip_address>:<your_server_port>/, i.e : .The "/" at the end is exactly signalizing, that your application is running under root context path, thus is accessible under  "/". So now we now, that the "magic slash" is signalizing the context path of our application. Logically, if our application is accessible under /application, then the context path of our application is "application".

One important thing to notice is, that Liferay OOTB uses some friendly URL's to identify all webs in portal. So your portal URL does not look like, but maybe like , or . This is because Liferay uses the keyword web to access public pages of a group (organization, community or user) and the keyword group to access private pages of mentioned groups. These keywords are of course configurable, so you can select your own keywords, which will be used to access your private and public pages.. It's important to not mix these terms with term of context path.

So now we know, what the context path is, we also know, which URL's are used to identify private and public pages in Liferay portal. So let's go straight to something more complicated. As I previously mentioned, Liferay Portal is by default using the root context path, thus accessible directly under  Let's take an example, when you want your Liferay portal to be accessible under As a matter of fact, you can accomplish this in different ways, i.e by configuration on HTTP server, or some redirection, but we will explain here, how this can be achieved on the level of Liferay portal.

Before we start, make sure that your Application server is stopped.

First of all, let's take a look at your current installation of Liferay portal. Let's assume, you are using Apache Tomcat as your servlet container. So let's look at your folder <installation-path-of-your-apache-tomcat>/webapps. In this folder you should see at least 1 folder called ROOT. This is the current installation of your Liferay portal, accessible under context path /.

Once you have this folder, you can rename to a new name signalizing your context path. So if you want your portal to be accessible under /portal, let's rename ROOT to portal. This renaming causes your portal to be accessible under a new context path.

Anyways, because there are some internal processes in Liferay Portal using the context path as well, we need to set a special property in Liferay portal. For this purpose let's find (or create a new if it does not exist yet) the file This should be located under <installation-path-of-your-apache-tomcat>/webapps/<your-renamed-liferay-folder>/WEB-INF/classes. As mentioned before, if this file does not exist by you, create a new one.

In this file, add the following line:


Instead of  <your-context-path> you should write the new context path. So if your renamed your ROOT folder previously to portal, then you should write the following line here:


Lastly, you'll need to navigate to <installation-path-of-your-apache-tomcat>/conf/Catalina/localhost. There will be a file called ROOT.xml, just rename it to match your context path, in our case portal.xml.

So, that's it. Your portal was now migrated to a new context path and you can start the application server. After starting, it should be accessible under your new selected context path, so in this example under /portal.

Well, that's it. The thing is, that even if you migrated your portal succesfully using previous steps, there are some issues, that need to be solved. Once you had in your portal some Web content articles previously refferencing to your documents, internal pages or images, all these will be broken. This is because Liferay is storing all refferences to these resources in a form of static text, thus not changing the links after change of context path. But no panic, we have a solution for this. I have developed a portlet plugin, which is after deployment accessible in control panel and allows you to migrate all your articles to new context path in all your organizations/communitites. This plugin is a port of community plugins and accessible here :

So have fun and let me know, if you have some problems/questions issues either with migration or using this plugin!


Moyenne (2 Voter)
L'estimation moyenne est de 4.5 étoiles sur 5.
Réponses Auteur Données
Hi, Our client requirement is to have two... Balaji Murugesan 3 août 2011 00:08
Hi Balaji, I think this should be no problem.... Jan Gregor 5 août 2011 05:28
Hi, after trying to change the context path... Inge Klein 1 septembre 2011 05:10
Nice Article Jan !!! Jignesh Vachhani 29 septembre 2011 03:08
This smells like a hack, meaning changing files... Alex Leshinsky 30 novembre 2011 18:15
How to get this context path inside custom... Manoj Satyagi 18 avril 2012 21:11
virtual path can be used Gowtham Mani 7 mai 2012 05:18
I have tried to localize the plugin but I can't... Rafael Lluis 28 janvier 2013 02:54
Hi Rafael, were you able to get the portlet... Rohit Gupta 25 février 2014 12:08
You can find it on the marketplace: ... Rafael Lluis 25 février 2014 12:19
i am looking for the portlet-plugin referred in... Rohit Gupta 25 février 2014 12:06

Our client requirement is to have two instances of portal. So can we have different Context path for the new instance that we create in LR portal.

Eg: 1st instance -
2nd instance -

If its not possible, how can we achieve the requirement.

Publié le 03/08/11 00:08.
Hi Balaji,

I think this should be no problem. Take a look at virtual hosts section at liferay admin guide.

Publié le 05/08/11 05:28 en réponse à Balaji Murugesan.
after trying to change the context path from "/" to "/public" and after migrating my organization CDX by help of the migration tool, the my CDX pages are not displayed properly anymore. The links are updated, but the page looks broken, it seems, that the stylesheet information can not be found anymore (no colours etc.). The organization CDX uses the jedi theme and a 3 column layout. Are there any extra steps to include the jedi theme and the 3 column layout ?
Publié le 01/09/11 05:10.
Nice Article Jan !!!
Publié le 29/09/11 03:08.
This smells like a hack, meaning changing files inside container's file structure.
I'm looking for a more "graceful" approach, i.e. building the portal from the source so that the installed instance will be mounted to the specified context root.
What configuration should I make before running ant deploy ?
Publié le 30/11/11 18:15.
How to get this context path inside custom portlets ? Any idea ?
Publié le 18/04/12 21:11 en réponse à Alex Leshinsky.
virtual path can be used
Publié le 07/05/12 05:18 en réponse à Manoj GT.
I have tried to localize the plugin but I can't find it (­talog/products/8246761) does anyone have tried it with success?
Publié le 28/01/13 02:54.
i am looking for the portlet-plugin referred in his post. The link­alog/products/8246761, doesn't work. Can somebody please help!!
Publié le 25/02/14 12:06.
Hi Rafael, were you able to get the portlet plugin?
Publié le 25/02/14 12:08 en réponse à Rafael Lluis.
You can find it on the marketplace:
Publié le 25/02/14 12:19 en réponse à Rohit Gupta.