Remove Web from URL
Liferay uses a default prefix for URLs that go to friendly URLs to differentiate them from those that go directly to the main controller. That means that they are usually of the form:
This path is quite simple, but sometimes even more simple paths or even tailored paths are desired. There are two ways to customize the path, Virtual Hosting or external URL rewriting. Let's see both
Virtual Hosting #
Virtual Hosting (Communities) is a feature of Liferay that allows converting the website of a community into a whole website of its own with its own domain.
When doing this, the domain already identifies the community, so there is no need to use the prefixes /web nor the friendly community path. So you'll be able to have URLs such as:
Liferay 4.1.X #
- Make sure you have Virtual Hosting (Communities) activated
- Edit portal-ext properties and set:
From now on Liferay will generate URLs without the web prefix.
Liferay 4.2 and later #
Since 4.2, by default this is active. so you don't need to do any configuration changes. Just activate the virtual hosting by giving a community a virtual host domain through the web UI.
URL Rewriting #
URL rewriting is a technique to modify the URL of an incoming request and convert it into another. The result of the conversion can be made completely transparent to the end user or (through a redirect) it can be made so that the change is also seen in the browser URL.
To use this technique an external web server that supports rewriting (such as Apache) is needed. That's usually not a problem since in most production environments such as web frontend is desired and used anyway.
The following links provide documentation about how to use URL rewriting for the most used versions of Apache:
- Apache 2.0: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
- Apache 1.3: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html