« Back to Customization

Remove Web from URL

Introduction #

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:

 /web/{communityFriendlyPath}/somePage

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:

 /somePage

Liferay 4.1.X #

  1. Make sure you have Virtual Hosting (Communities) activated
  2. Edit portal-ext properties and set:
 layout.friendly.url.virtual.hosting.url.shorten=true

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
0 Attachments
23162 Views
Average (1 Vote)
The average rating is 1.0 stars out of 5.
Comments
Threaded Replies Author Date
is there any storage limit? delang j July 13, 2009 11:20 PM
http://www.liferay.com/community/forums/-/messa... John Nguyen September 13, 2012 1:16 PM
You say, quote: »Liferay uses a default prefix... Jochen Uebel September 10, 2013 2:28 AM

is there any storage limit?
Posted on 7/13/09 11:20 PM.
http://www.liferay.com/community/forums/-/message_boards/message/447746

doesn't answer how to get rid of web for multiple community sites without using the same domain. The desired result is to NOT use subdomains, in which that's what the virtual host method does. It just needs to be domain.com/comunityname/page instead of domain.com/web/community/page.
Posted on 9/13/12 1:16 PM.
You say, quote:
»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 …«
Whereas it’s fine to differntiate friendly URLs from URLs to the main controller, you should not have put a prefix to the friendly ULR at all—but to the URL directing to the main controller!
What is more important—backend URL or public URL?
Obviously the latter.
Or am I wrong?
Posted on 9/10/13 2:28 AM.