jeudi 30 avril 2015

htaccess accept language from the browser and redirect

I have some questions to accept languages and htaccess. I have a multilanguage homepage. In the root directory are only the robots.txt, .htaccess, sitmaps and the directories for the languages de for german and en for english. What I do need is that the browser indenified the right language. If are not the languages german or english, then choose english as the default language.

The problem is that the forwarding does not work correct. I type http://example.com than I am redirected to http://ift.tt/1EtjfWz wihtout any css styles. When I click on a link than I am redirected to hxxx://www.webpack.de/de/anysite.php

My domain is not there. What is wrong? Please take a look to my .htaccess.

Thank you for your help. Sorrry I can't post more than 2 links.

Jklein

/root
|-index.php
|-de
|-en
|-robots.txt
|-sitemap.xml
|sitemap-de.xml
|sitemap-en.xml

.htaccess

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{REMOTE_ADDR} !^10\.30\.7\.1(?:37|38|39|40)$
RewriteRule ^ http://ift.tt/1BzhSUh} [R=301,L]

RewriteCond %{HTTP:Accept-Language} ^en [NC]
RewriteRule ^$ http://example.com/en/ [L,R=301]

RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^$ http://example.com/de/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

# for all other languages use English
RewriteRule ^$ http://example.com/en/ [L,R=301]

RewriteRule ^(en|de)/?$ index.php?lang=$1 [QSA,NC,L]

Aucun commentaire:

Enregistrer un commentaire