Sunday, August 23, 2009

Virtual hosts with liferay - handling of "subdomain" www

As you might have noticed there were no major changes lately. But yesterday at least I did a lot of cleanups with the team. Most of them were content related - but one basic thing could be interesting for you as well: Fine tuning virtual hosting.

We are using the "virtual host" feature of liferay a lot.
(Control panel -> Server -> Portal instances)

Unfortunately you can just enter one single virtual host ID here. Usually the domain plus the www subdomain/prefix. (e.g. www.traumtube.de )
If a user now enters the URL without the subdomain (here: http://traumtube.de) he would not get to the intended page but to the first (default) virtual host. Reason is: Liferay doesn't match the HTTP_HOST as it doesn't match including the subdomain.

Finally I came up with a solution using Apaches mod_rewrite to achieve the desired flexibility:

RewriteEngine On
RewriteOptions Inherit
RewriteCond %{HTTP_HOST} !^www\.traumtube\.de [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.traumtube.de/$1 [L,R,NE]
Whoopie - that helped.

Hope that helps somebody with the same issues.
Cheers!

2 comments:

  1. I am hunting for and i love to article a comment that "The information of one's post is awesome" Terrific work!

    =======================================================
    Best website designing company in Kanpur

    ReplyDelete
  2. very amazing blog content with informative content in this aarticle
    =================
    Software development company in kanpur

    ReplyDelete

I'm happy about every feedback! :)