Sunday, May 10, 2009

Liferay Virtual Hosting & Friendly URLs

Virtual hosting is an important feature in Liferay that allows you to customize Liferay URLs to suit your needs. You may want to customize the URL for SEO reasons or user friendliness or you may just not like having that '/web/guest/home' in the URL.

What is the /web/guest/home for anyway?

First let us try to understand what it means. The name of the servlet that deals with incoming requests is the 'web' servlet and hence '/web/ is a mapping to that servlet. Obviously '/guest' maps to the 'Guest' community i.e. your public facing pages. And 'home' is the name of the page you are requesting within that community.

Remove /web/guest/home through Liferay Virtual Hosting

After you login as an administrator user, click on the 'Control Panel' under the dock.

Click on 'Communities' under the 'Portal' tab on the left hand side. 

You should see the following page with all your communities.

Click on the actions button and select 'Manage Pages' for the community you want to setup Virtual Hosting for.

On the next page click on 'Settings'

Then select 'Virtual Hosting'

Enter the domain name for your website. For purposes of this How To document I added an entry in my local hosts file to get this working locally. On a public portal you would just enter

Save the new settings and go ahead and test it. You should now only see the name of the page after the URL. 

This is really handy when it comes to search engine optimization since the URL of a page is really important and the '/web/guest/' component of it does not add any value to the URL, in fact it kind of dilutes your URL when it comes to search engines.

You can do this for your other communities as well. So if this were an organization portal, your members virtual host can be '' and your staff can be ''. 

Feel free to drop me a line and share this How To.


  1. Anonymous12:09 AM


    Very good article.Thanks a ton !
    I couldnt locate a better explanation for fixing the URL think.


  2. No problem. Glad you found it useful.

    Feel free to link to this elsewhere, or on other forums : )


  3. I want to do the same thing but with separate portal instances. As I've already entered the site's URL when creating the new portal instance Liferay won't let me enter it again for the virtual host - so I'm stuck! Any suggestions?

  4. Anonymous5:35 AM

    It didn't work for me. I have Liferay 5.2.3. If I do those things, and after that logout, it still goes to /web/guest/home...Why? Do I have to do something else?

    Please help me!

  5. @Phil: Haven't tried that before with multiple instances, sorry. If it works for me I'll document it here on another post. If you have multiple liferay installs you should be able to point each to a different domain there, assuming each liferay handles requests coming for the corresponding domain. Did you try with 1 liferay + multiple communities?

    @Anon: did you assign your computer the same name in your hosts file that matches what you entered? It has to be a domain name, not an IP address.

  6. Anonymous6:55 AM

    I have Liferay only in my localhost. And I used "localhost:8080" as a public virtual host. Is the localhost the problem?

  7. Anonymous12:40 AM

    but when i looked at the logs it is showing me exception for virtual host- filter.Could you please advise what could be done to fix the same.