User Interfaces may get affected when using friendly URL routing and mapping. URL routing or mapping could shorten URL, as you can see in browsers. A route is a pattern for a URL. It includes named fragments automatically parsed from the URL into the parameter map. Every URL parsed by a route could also be generated from the resulting parameter map. Abstracted from the book: Liferay User Interface Development.
In addition, the portal is integrated with UrlRewrite filter. Based on the mod_rewrite for apache, UrlRewrite filter is a Java Web Filter for any J2EE compliant web application server, such as Resin, Orion, or Tomcat, which allows us to rewrite URLs before they get to the code. Refer to http://tuckey.org/urlrewrite/. Performance on the UrlRewrite filter is very good and the UrlRewrite filter allows for convenient configuration of URLs where JkMount is pointing to /* or the web server isn't running behind Apache. Abstracted from the book: Liferay Portal 6 Enterprise Intranets
In brief, Liferay provides friendly URL framework and integrate UrlRewrite filter. This article will consider more specific use cases.
- Use case A: home URL for each web site should be configurable; and hide home URL when hitting domain name only;
- Use case B: keep existing web content SEO friendly URL AS IS; when hitting these web content friendly URL, display that web content without redirecting behaviors;
- Use case C: provide new configurable SEO friendly URL for newly created web content; when hitting these web content friendly URL, display that web content without redirecting behaviors;
This article is going to show how to implement above use cases as new features in Liferay 6.
Configurable home URL
For the use case A, considering scenario: there is one portal instance, two groups (either communities or organizations): street and workshop. Each group has its own virtual host like street.bookpub.com, workshop.bookpub.com. Each group has its own public pages and private pages.
For example, the group street has following page structure
Home
Test
Demo
Resource
Help
And each page has its own friendly URL like /home, /resource, /help, /test, /demo
For instance, the group workshop has following page structure
Help
Resource
Test
Demo
Home
And each page has its own friendly URL like /help, /resource, /home, /test, /demo
Requirements:
- Set home URL globally – scoped to portal-instance, like /test
- When hit URL: http: //street.bookpub.com[/], it should show the page /test of the group street;
- No redirect in the picture; that is, the URL http: //street.bookpub.com[/] stays non-changed.
- When hit URL: http: //workshop.bookpub.com[/], it should show the page /test of the group workshop;
- Again there is no redirect in the picture; that is, the URL http: //workshop.bookpub.com[/] stays AS IS.
Is this useful use case?
Web content SEO friendly URL
For the use cases B and C, considering scenario, there are thousands press release articles got released in past ten years. Each article has its own SEO friendly URL, like http://street.bookpub.com/dlls/2011/prod_030311c.html. The URL has following pattern.
http://street.bookpub.com/dlls/${year}/${title.name}.html
Where ${year} stands for the value of the year, like 2011; ${title.name} stands for SEO friendly title, created by editorials. The title will take characters a-z, A-Z, 0-9, and “ -_.” (empty space, hyphen, underscore, period).
Now it is time to use Liferay WCM to manage all press release articles, while all SEO friendly URLs should get supported AS IS.
Similarly, manage features, videos and pod casts in WCM of Liferay as well. After migration, new press release articles, features, video and pod casts will have new friendly URLs with following pattern.
http://street.bookpub.com/${type.name}/${id.value}/${title.name}
Where {type.name} could have values: release, feature, video, and podcast; ${id.value} presents article ID value; ${title.name} stands for SEO friendly URL title, created by editorials.
And set the list of article types, for example:
journal.article.types=announcements,blogs,general,news,release,feature,video,podcast
Are these useful use cases?
Solution proposals
- Add following properties
## Home URL enabled or disabled
virtual.host.home.url.enabled=true
## Default home URL value. It will be used only if the property
## virtual.host.home.url.enabled is true, and home URL in Control Panel
## settings has value NULL.
## That is, home URL value could be reset in Control Panel
virtual.host.home.url.name=/test
- Implement home URL as new feature.
- Implement web content friendly URL as new feature
Testing results
home URL for street.bookpub.com
home URL for workshop.bookpub.com
Web content existing friendly URL
Web content SEO friendly URL
Summary
As you can see, Liferay could be used as a framework to present any kind of SEO friendly URL. For testing purpose, these features would be available as a fix patch for Liferay 6.0.
Last but not least, I'd like to send special thanks to Eduardo Carneiro, Rommel Bermudez, Duncan McKeever, Mark Wynne who provided these requirements.

