Forum Moderators: phranque
RewriteCond %{SERVER_NAME} .*(example).*$ [NC] ----> Captures URL
RewriteCond %{REQUEST_URI} .*\/h-(.{2}/).* [NC] ----> Capture the language after h-
RewriteRule ^.*\/h-(.{2}/).* http://www.example.$1 [R=301,NE,QSA,L] ----> So, i redirect to the right domain.
RewriteRule ^/$ /webapp/wcs/stores/servlet [P,NE,QSA,L] -> i redirect any / to the servlet (forget this if you want)
So you mean to set an additional RewriteCond just below the REQUEST_URI?
is possible to capture on a ENV variable just the last part of the HTTP_HOST?
That is www.example.xx, just the xx
An HTTP request header field (see RFC2616 for more information about these); for example: Host, User-Agent, Referer, and Accept-Language. A regular expression may be used to specify a set of request headers.
...
Since version 2.0.51 Apache will recognize occurrences of $1..$9 within value and replace them by parenthesized subexpressions of regex.
A couple of things need to be determined from the request in order to make the dynamic virtual host look like a normal one. The most important is the server name, which is used by the server to generate self-referential URLs etc. It is configured with the ServerName directive, and it is available to CGIs via the SERVER_NAME environment variable. The actual value used at run time is controlled by the UseCanonicalName setting. With UseCanonicalName Off, the server name is taken from the contents of the Host: header in the request. With UseCanonicalName DNS, it is taken from a reverse DNS lookup of the virtual host's IP address. The former setting is used for name-based dynamic virtual hosting, and the latter is used for IP-based hosting. If httpd cannot work out the server name because there is no Host: header, or the DNS lookup fails, then the value configured with ServerName is used instead.