I'm trying to redirect pages in a way that the language indicator, which in the URL is expressed as a subfolder ("en/", "de/" ...), is converted to a parameter I can work with. "FR", as the site's main language, does not have a language subfolder.
To illustrate this:
www.domain/index.html
should redirect to
www.domain/index.php?lang=fr
and
www.domain/en/index.html
should redirect to
www.domain/index.php?lang=en
I've tried the following in my .htaccess file (which is located in the root directory):
RewriteEngine On
RewriteRule ^en/index\.html$ /index.php?lang=en [L]
RewriteRule ^de/index\.html$ /index.php?lang=de [L]
RewriteRule ^index\.html$ index.php?lang=fr [L]
The last one works as expected, however the first two return a 404. For the second line ("de version"), I get:
The requested URL /de/index.php was not found on this server.
Apache logs the following:
[Thu Jul 09 13:14:28 2015] [error] [client ::1] script '/Applications/MAMP/htdocs/testsite/de/index.php' not found or unable to stat
It would appear that the first two rules are completely ignored by the server, as changing the target file name in the second line as below:
RewriteRule ^de/index\.html$ /blah.php?lang=de [L]
still triggers the same 404 message stating the missing de/index.php and not blah.php ;
What does work however is placing a .htaccess in a subfolder named 'de' and pointing from there to the index.php in the root folder with
RewriteRule ^index\.html$ /index.php?lang=de [L]
But that's not a proper solution, is it ?