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

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"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.