Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

270
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda