Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!