How to remove “/web/guest” from Liferay URL’s
Op 19 mei 2010 door Kristof Verbraeken in categorie Liferay
From the moment you give Liferay a try and start your portal for the very first time you’ll notice something a bit dirty about Liferay URL’s.
That’s right: I’m talking about the “/web/guest” prefix in the frontend. In the early days I was working with Liferay, I just thought that it was some “Java web development hocus pocus thing” that you will just have to accept when doing a Liferay implementation.
Keeping the prefix in your URL’s is certainly not a disaster, but for SEO matters clean URL’s are prefered.
It’s always a good idea to check the Liferay "portal.properties" first for properties that might be interesting for your Liferay implementation. You’ll find some properties in portal.properties that seem interesting regarding URL’s in Liferay.
Check out these properties:
layout.friendly.url.private.group.servlet.mapping=/group
layout.friendly.url.private.user.servlet.mapping=/user
layout.friendly.url.public.servlet.mapping=/web
Looks great doesn’t it? It looks like we can get rid of the “/web/guest” very easily! Just fill in an empty string for the "layout.friendly.url.public.servlet.mapping property" and we should be all done, right? I warn you though: don’t do this! Because you will break your Liferay installation completely and you won't be able to reach your portal anymore.
This is not the way to remove the “/web/guest” from Liferay URL’s. The right answer: take a closer look at Virtual Hosting in Liferay. There’s already an article on the Liferay Wiki about this topic.
In short:
1. The layout.friendly.url.private.group.servlet.mapping property (/group by default) is mapped to the private pages of a community.
2. The layout.friendly.url.public.servlet.mapping property (/web/ by default) is mapped to the public pages of a community.
3. The layout.friendly.url.user.servlet.mapping property (/user by default) is mapped to the user pages.
What we’re going to do through Virtual Hosting is mapping one domain directly to the public pages of a community. When this mapping exists Liferay no longer needs the “/web/guest” prefix (and other mappings listed above) to know which community a visitor is accessing (with the “/web/guest” prefix you are accessing the public pages of the Guest community).
In the steps below I will show you how to remove the “/web/guest” from the frontend of a Liferay portal.
1. Add a new Liferay instance (only if needed) You must be logged in (as omniadmin) to do this. In this example I’m adding a new instance for the domain e-kon.dev.

2. Have a closer look at the frontend. When you browse to the newly added instance you’ll see that the “/web/guest” is present in the URL’s.

3. Configure the Virtual Hosting
Log in (as an Administrator) and go to the Communities overview.

Choose Manage pages in the overview

Choose Settings in the tabs.
For the Public Virtual Host (this will be mapped to the Public Pages) enter "www.e-kon.dev". You can leave the Private Virtual Host just empty.

4. Check the frontend again and browse to www.e-kon.dev. You’ll notice that “/web/guest” is no longer present in URL’s! Note that you can still access pages with the “/web/guest” prefix!

All done.
I hope this article was useful to all Liferay developers out there. Feel free to comment or ask questions about the Virtual Hosting feature in Liferay through our comment section. Do you know other ways to handle this?



Wacht op zijn afspraak... 