Breiti
Breiti

Reputation: 589

Liferay Top Level Friendly URL

Is there a way to create / process friendly URLs in liferay like this?

http://myserver.com/JonDoe

... where John Doe is the name of a clients whose data should be displayed.

A little more detail:

I am not talking about getting rid of the "web" or "group" for friendly urls, I am taking about having a friendly url right after the first "/".

We want to create URLs in the form of http://server/ClientName where ClientName resolves to the name of a Client. This is an issue since normally liferay would expect a friendly URL after the first "/". So we ned to intercept that somehow.

The process should be like this (pseudo code):

1) inspect values after first "/"

2) If value after "/" is the name of a client, send user to client display page and display client information

3) If there is no client with the given name, interpret it as friendly url and do normal liferay behaviour.

Is there a way to do this in liferay ?

Upvotes: 0

Views: 472

Answers (2)

Tobias Liefke
Tobias Liefke

Reputation: 9032

If you want to have one URL for a page, you can just set the friendly URL for that page (see Olafs remark about virtual hosts as well)

If you want to have a limited set of URLs for one page, you can create a page of type Link to Page for each URL and select the original page. To identify the current URL when rendering you portlet you can use PortalUtil.getCurrentURL(renderRequest)

If you want to have many URLs for one page you could use a FriendlyUrlMapper, which allows URLs like http://myserver.com/page/-/myPortlet/JonDoe.

If you want to have many "root" URLs (i mean without the /page/-/myPortlet part), you will have to create an Liferay EXT plugin, extend com.liferay.portal.util.PortalImpl and overwrite getPortletFriendlyURLMapperLayoutQueryStringComposite. I've done the same by implementing a strategy that checks if a page exists for a specific given URL and otherwise uses the URL as parameter for a FriendlyURLMapper.

Upvotes: 1

Olaf Kock
Olaf Kock

Reputation: 48087

Sounds like you want to get rid of the /web/ or /group/ parts of the URLs? This is possible with proper configuration of the virtual host - you'll map the site to the domain name, then you have total freedom to name the pages, even hierarchically (e.g. /JonDoe/home)

So far this was simple configuration. If you want /JonDoe to point to another site than /JoeShmoe (e.g. just get rid of /web/ or /group/), you'll have to dig deeper and write quite some customization plugins that change the name resolving (and generation of URLs)

Upvotes: 1

Related Questions