0

Hi together,
I need to make a redirection in apache, so the user is redirected according to his/her browser language settings to the appropriate subdirectory, where the index.html file in the according language is stored. I use AliasMatch because I don`t want user to see the whole path for the webproject.

So I edited the httpd.conf with following 2 lines:

AliasMatch ^(?:/(?:en¦es¦fr¦ja¦ko¦ru))?(/.*)?$ "/usr/local/apache2/htdocs/MyProject/eng$1"

AliasMatch ^(?:/(?:de))?(/.*)?$ "/usr/local/apache2/htdocs/MyProject/de$1"

The problem is as following:
the apache doesn`t evaluate the second alias match. It redirects all requests to the english version, for all of the language settings.

I suppose, I should design the regular expression, so that apache woudn`t be able to execute the first AliasMatch in case the given language settings are not available.

Woulld you give me any hints, HOW I can achieve this?

Thanks for your help

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by afbach
0

So I edited the httpd.conf with following 2 lines:

AliasMatch ^(?:/(?:en¦es¦fr¦ja¦ko¦ru))?(/.*)?$ "/usr/local/apache2/htdocs/MyProject/eng$1"

AliasMatch ^(?:/(?:de))?(/.*)?$ "/usr/local/apache2/htdocs/MyProject/de$1"

Thanks for your help

Yeah, your first RE has the '?' (zero or one) around the whole of the alternative, which means the first RE will match everything. Try:

AliasMatch ^(?:/(?:en¦es¦fr¦ja¦ko¦ru))(/.*)$ "/usr/local/apache2/htdocs/MyProject/eng$1"

AliasMatch ^(?:/de)(/.*)$ "/usr/local/apache2/htdocs/MyProject/de$1"

That is:
www.you.com/en/himom.html ->
"/usr/local/apache2/htdocs/MyProject/eng/himom.html"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.