babel
babel copied to clipboard
Idea: redirect based on browser-language
I was thinking about a nice feature? It's maybe nice to create a sort of redirector plugin wich checks the browser language of the visitor and redirects them to the right context-site-url. In my case I have an "nl.domain.com" and "en.domain.com". Wen someone comes trough "www.domain.com" or just "domain.com", it would be nice if they redirects to the right part.
When a language is unknown in the contexts, just redirect to the first/default context.
I'm planning to provide this feature in a future version of Babel. Till then you may work with rewrite rules based on the Accept-Language HTTP header var. You may have look at this tutorial: http://www.class-zec.com/en/blog/2011/seo-friendly-multilingual-websites-with-modx-and-babel.html
okay, thanks for your reply.. I will try to create this feature for now on my own, maybe when I have finished it I could send you it here so you could determine if you want to use it! Thanks for now
It´s exactly what i need1!!!
gadamiak has done this: https://gist.github.com/gadamiak/3812853
Available as transport package on http://modx.com/extras/package/langrouter
Easy to do with htaccess:
RewriteCond %{HTTP:Accept-Language} !^de [NC] RewriteRule ^$ en/ [R=301,L]
One big downside with this. You can't switch languages by choice.
So if you're visiting a website from a foreign computer, you're screwed. Also, some bots might never get to see the whole site with all languages.
This can be accomplished with a language-matching snippet like this: https://gist.github.com/sebastian-marinescu/4b2991bc40dbbc405257ba5846adb1ef
This is part of a routing extra and not part of Babel.