« Back to 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 mydomain.com/ and you want to make it accessible under mydomain.com/portal, 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 mydomain.com/.  Let's take an example, when you want your Liferay portal to be accessible under mydomain.com/portal. 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 portal-ext.properties. 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 : http://www.liferay.com/downloads/liferay-portal/community-plugins/-/software_catalog/products/8246761

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


0 Attachments
Average (3 Votes)
The average rating is 4.666666666666667 stars out of 5.
Threaded Replies Author Date
Hi, Our client requirement is to have two... Balaji Murugesan August 3, 2011 12:08 AM
Hi Balaji, I think this should be no problem.... Jan Gregor August 5, 2011 5:28 AM
Hi, after trying to change the context path... Inge Klein September 1, 2011 5:10 AM
Nice Article Jan !!! Jignesh Vachhani September 29, 2011 3:08 AM
This smells like a hack, meaning changing files... Alex Leshinsky November 30, 2011 6:15 PM
How to get this context path inside custom... Manoj Satyagi April 18, 2012 9:11 PM
virtual path can be used Gowtham Mani May 7, 2012 5:18 AM
I have tried to localize the plugin but I can't... Rafael Lluis January 28, 2013 2:54 AM
Hi Rafael, were you able to get the portlet... Rohit Gupta February 25, 2014 12:08 PM
You can find it on the marketplace: ... Rafael Lluis February 25, 2014 12:19 PM
i am looking for the portlet-plugin referred in... Rohit Gupta February 25, 2014 12:06 PM

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 - www.example1.com
2nd instance - www.example2.com/portal

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

Posted on 8/3/11 12:08 AM.
Hi Balaji,

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

Posted on 8/5/11 5:28 AM in reply to 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 ?
Posted on 9/1/11 5:10 AM.
Nice Article Jan !!!
Posted on 9/29/11 3:08 AM.
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 ?
Posted on 11/30/11 6:15 PM.
How to get this context path inside custom portlets ? Any idea ?
Posted on 4/18/12 9:11 PM in reply to Alex Leshinsky.
virtual path can be used
Posted on 5/7/12 5:18 AM in reply to Manoj GT.
I have tried to localize the plugin but I can't find it (http://www.liferay.com/downloads/liferay-portal/community-plugins/-/software_ca­talog/products/8246761) does anyone have tried it with success?
Posted on 1/28/13 2:54 AM.
i am looking for the portlet-plugin referred in his post. The link http://www.liferay.com/downloads/liferay-portal/community-plugins/-/software_cat­alog/products/8246761, doesn't work. Can somebody please help!!
Posted on 2/25/14 12:06 PM.
Hi Rafael, were you able to get the portlet plugin?
Posted on 2/25/14 12:08 PM in reply to Rafael Lluis.
You can find it on the marketplace:

Posted on 2/25/14 12:19 PM in reply to Rohit Gupta.