I am trying to create an i18n app with French and English languages, the deployment issue is not working. this my htaccess file
RewriteEngine on
RewriteBase /
RewriteRule ^../index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (..) $1/index.html [L]
RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule ^$ /fr/ [R]
RewriteCond %{HTTP:Accept-Language} !^fr [NC]
RewriteRule ^$ /en/ [R]
and here is the result in the browser (https://ibb.co/Z1z9qtk)
This is what works for me.
For French, have the .htaccess file inside server.com/fr/ directory.
RewriteEngine On
RewriteBase /en
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ %{DOCUMENT_ROOT}/fr/index.html
I am also copying the htaccess to the root of dist folder by making use of angular json file.
angular.json file
{
...
"i18n": {
"sourceLocale": "en-US",
"locales": {
"fr": "src/locale/messages.fr.xlf",
"en": "src/locale/messages.xlf",
"baseHref": ""
}
},
"architect": {
"build": {
...
},
"configurations": {
"production": {
...
},
"development": {
...
},
"fr": {
"localize": [
"fr"
],
"assets": [
{
"glob": ".htaccess", "input": "src/assets/fr/", "output": "/"
}
]
},
"en": {
"localize": [
"en"
],
"assets": [
{
"glob": ".htaccess", "input": "src/assets/en/", "output": "/"
}
]
}
},
"defaultConfiguration": "production"
},
...