Htaccess And Url For Multilingual Site

- 1 answer

I'm ready to use the subdirectory format for my multilingual website. My first question is: For SEO, have I to translate the page name in the url or it is useless? Example:

- Same filename


- Different filename

Then, when user is on Should I redirect him to and depending user's IP? Or have I to set a default local, and have my url like and

Finally, what is the best way to get the local from user's current URL? Parsing url to get /fr or /en, or add a GET parameter in url with lang=fr (hidden with htaccess)

Thanks :)



As a precondition, I assume that you are not using frameworks / libraries. Furthermore, I never have solved similar problems only using .htaccess (as the title of your question requests) and thus don't know if it is possible to do so. Nevertheless, the following guidelines may help you.

Your first question

In general, a web page's file name and path have influence on its ranking. Furthermore, having page names and paths in native languages might help your users memorize the most important of your URLs even without bookmarking them.

Nevertheless, I never would translate the page names or directories for pages which are part of a web application (as opposed to a informational or promotional pages).

The login page you mentioned is a good example. I am nearly sure that you do not want your site to be found because of its contents on its login page. Actually, there are many websites which exclude login pages and other application pages from being indexed at all.

Instead, in SEO terms, put your effort into your promotional and informational pages. Provide valuable content, explain what is special about you or your site, and do everything you could that those pages get properly indexed. IMHO, static HTML pages are the best choice for doing so.

Furthermore, if you translate the names of pages which belong to your actual application, you will run into massive trouble. For example, after successful login, your application probably will transfer the user to his personal dashboard, which probably will be based on another HTML template / page. If you have translated that page name into different languages, then your application will have to take care to take the user to the right version. Basically, that means that you need as many versions of your application as languages you want to support. Of course, there are tricks to make life easier, but this will be a constant pain and definitely in no way worth the effort.

To summarize: Create static pages which show your USP (unique seller position) and provide valuable content to users (for example sophisticated tutorials and so on). Translate those pages, including names and paths, and SEO them in every way you could. But regarding the actual application, optimizing its pages is kind of pointless and even counterproductive.

Your second question

I would never use IP based redirecting for several reasons.

First, there are many customers in countries which are not their home country. For example, do you really want to redirect all native English speakers to your Hungarian pages because they are currently in Hungary for a business trip?

Second, more and more users today are using VPNs for different reasons, thereby often hiding the country where they currently are.

Third, which IP address belongs to which provider or country is highly volatile; you would have to constantly update your databases to keep up.

There are more reasons, but I think you already have got the idea.

Fortunately, there is a solution to your problem (but see "Final remark" below): Every browser, when fetching a page from a server, tells the server the preferred and accepted languages. For example, Apache can directly use that information in Rred and accepted languages. For example, Apache can directly use that information in RewriteRule statements and redirect the user to the correct page.

If you can't alter your Server's configuration, then you can evaluate the respective header in your CGI program.

When doing your research, look for the Accept-Language HTTP 1.1 header. A good starting point probably is here.

Your third question

You eventually are mixing up two different things in your third question. A locale is not the same as a language. On one hand, you are asking " get the local from...", and on the other hand, you say "...lang=fr...", thus making the impression you want to get the language.

If you want to get the language: See my answer to your second question, or parse the language from the current path (as you already have suggested).

If you want to get the locale, things are more complicated. The only reasonable automatic method is to derive the locale from the language, but this will often fail. For example, I generally prefer the English language when doing research, but on the other hand, I am located in Germany and thus would like dates and times in the format I am used to, so deriving my desired locale from my preferred language will fail.

Unfortunately, there is no HTTP header which could tell the server which locale the user prefers. As a starting point, this article may help you.

See the final remark (next section) on how to solve this problem.

Final remark

As the article linked above already states: The only reliable way to satisfy the user is to let him choose his language, his locale and his time zone within your application. You could store the user's choices either in cookies or in your back-end database; each has its own advantages and disadvantages.

I usually use a combination of all methods (HTTP headers, cookies, database) in my projects.