Greg Greg - 2 years ago 264
HTML Question

Redirect users based on browser language (not in php)

My website will be in 3 languages. French (fr) is the default language.
The structure of the site is the following:

Root directory (note: I'm not using php files, just plain html)




I got questions:

  • What is the best practice to redirect users based on their web browser language? Via htaccess?

  • Do I need a index.html page at root level (for SEO reason or any other reason) ? The French index.html perhaps?

Answer Source

Super easy tool here:

Makes life incredibly easy for htaccess redirects based on the browser's language.


RewriteEngine on
RewriteCond %{HTTP:Accept-Language} (fr) [NC]
RewriteRule .* /fr/index.html [L]
RewriteCond %{HTTP:Accept-Language} (en) [NC]
RewriteRule .* /en/index.html [L]
RewriteCond %{HTTP:Accept-Language} (de) [NC]
RewriteRule .* /de/index.html [L]

This is a hard redirect, the browser's location bar will indeed show the new page. Though, this is better for UX than an internal redirect masking the URL.

To answer your question, it is highly regarded that an index.html provides the best UX. However, that's essentially because people have come to expect this in general (,, etc.). SEO-wise, no, you wouldn't get dinged if you didn't follow that same structure.

Best practice is to use your best guess (like the htaccess), and still offer a menu for switching languages. Plus, you'll also need a fallback for if the Accept-Language isn't actually defined (like going to /en/ by default). This could be a final line in the htaccess, or it could simply be an index.html at the root level, where .htaccess is.

Other than that, there's not a tremendous amount that goes into localization.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download