Redirect According To The User's Language

| | Comments (0) | TrackBacks (0)
Redirecting according to the language that a user has set is actually fairly easy. The most important thing to remember is to put the most specific first.

For example to set up site with Irish, French and English as the fallback/default:

RewriteEngine on
# Irish Users
RewriteCond %{HTTP:Accept-Language} ^ga [NC]
RewriteRule ^$ /ga/ [L,R=301]
# French Users
RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule ^$ /fr/ [L,R=301]
# Default Page
RewriteRule ^$ /en/main-page [L,R=301]
For a full list of languages, the best I've found is from Perl's I18N-LangTags module.

0 TrackBacks

Listed below are links to blogs that reference this entry: Redirect According To The User's Language.

TrackBack URL for this entry: http://www.modrewrite.co.uk/cgi-bin/mt/mt-tb.cgi/3969

Leave a comment

About this Entry

This page contains a single entry by Niall Donegan published on March 15, 2010 1:26 PM.

Blocking Specific User Agents was the previous entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.31-en