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

230
Vistas
Redirecting to subfolder while displaying root URL with .htaccess language redirect and manual language selector

Apologies in advance for contributing to what must already be an exhaustive list of questions related to .htaccess redirects. My question concerns a client website consisting of multiple language versions, the folder structure being as follows:

index.html (default german version)
— en
  index.html
— fr
  index.html
— nl
  index.html
– css
– img
– js

Said client now asked me to implement a language redirect which I did by moving the default german version to its own subfolder and placing the following .htaccess in the root directory.

RewriteEngine On

# Redirect to dutch language version
RewriteCond %{HTTP:Accept-language} ^(nl.*) [NC]
RewriteRule ^$ /nl/ [L,R=302]

# Redirect to french language version
RewriteCond %{HTTP:Accept-language} ^(fr.*) [NC]
RewriteRule ^$ /fr/ [L,R=302]

# Redirect to english language version
RewriteCond %{HTTP:Accept-language} ^(en.*) [NC]
RewriteRule ^$ /en/ [L,R=302]

# Redirect all other languages to english language version
RewriteCond %{HTTP:Accept-language} !^(nl|fr|de|en).* [NC]
RewriteRule ^$ /en/ [L,R=302]

# Redirect to german language version
RewriteCond %{HTTP:Accept-language} ^(de.*) [NC]
RewriteRule ^$ /de/ [L,R=302]

The redirects themselves work as they should and don’t conflict with the manual language selector on each respective page. The only problem I am left with is that the URL shown in the browser includes the subfolder for the respective language, i.e:

mydomain.com/de/
mydomain.com/en/
mydomain.com/fr/
mydomain.com/nl/

While this is intended for the non-default languages (i.e. en, fr and nl), the URL should show the root address when visiting the default german version:

mydomain.com
instead of
mydomain.com/de/

How would I need to modify my .htaccessfile to achieve the desired behavior? I am testing the site from within a subfolder on the sites server called dev so the suggested solution should ideally work with mydomain.com and dev.mydomain.com alike.

Thanks very much in advance.

over 4 years ago · Santiago Trujillo
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