Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

271
Visualizações
htaccess config for i18n angular App don't work

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)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

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"
          },
          ...
      

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda