Htaccess takes language from browser and redirects
I have some questions to accept languages ββand htaccess. I have a multilingual homepage. The root directory contains only robots.txt, .htaccess, sitmaps and directories for de for German and en for English. I really need the browser to detect the correct language. If your languages ββare not German or English, select English as your default language.
The problem is that the forwarding is not working correctly. I am typing http://example.com than redirecting to https://www.webpack.de/example.com/de/index.php without any css styles. When I click on the link I am redirected to hxxx: //www.webpack.de/de/anysite.php
My domain does not exist. What's wrong? Please take a look at my .htaccess.
/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 ^ https://ssl.webpack.de/%{HTTP_HOST}%{REQUEST_URI} [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]
source to share
No one has answered this question yet
Check out similar questions: