« Retour - 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
Moyenne (1 Voter)
L'estimation moyenne est de 1.0 étoiles sur 5.
Commentaires
Réponses Auteur Données
is there any storage limit? delang j 13 juillet 2009 23:20
http://www.liferay.com/community/forums/-/messa... John Nguyen 13 septembre 2012 13:16
You say, quote: »Liferay uses a default prefix... Jochen Uebel 10 septembre 2013 02:28

is there any storage limit?
Publié le 13/07/09 23:20.
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.
Publié le 13/09/12 13:16.
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?
Publié le 10/09/13 02:28.