For the website of my wife’s company, www.exportmanagement.nu, I needed a simple approach to direct traffic to the proper pages based on the language preference setting of the visiting browser. It’s a very simple approach, any browser with Dutch as its language setting will be directed to the main site and any other language will be directed to a smaller, English language based, website. Luckily the swiss army chainsaw named mod_rewrite came to the rescue and the following little code fragment will do just that (placed in an .htaccess file).
RewriteEngine on
RewriteBase /
# All Dutch language browsers redirect to index.html
RewriteCond %{HTTP:Accept-language} ^nl [NC]
RewriteRule ^$ /index.html [L,R=301]
# All non-Dutch browsers redirect to index_en.html
RewriteRule ^$ /index_en.html [L,R=301]
The RewriteBase directive makes sure the rewrite rule only triggers when accessing the root of the website, any subsequent request for a specific page will not trigger the rewrite rule.
No related posts.
Comments
No one has said anything yet.
Leave a Comment