On my website I'd love to redirect visitors who speak italian (their language browser is italian) to /it/ and all other languages to /en/
I come up with the following code:
#redirect to /it for italian lang
RewriteCond %{HTTP_HOST} ^domain\.net$ [NC]
RewriteCond %{REQUEST_URI} !/it/ [NC] #doesn't have /it in the url already
RewriteCond %{REQUEST_URI} !/en/ [NC] #doesn't have /en in the url already
RewriteCond %{REQUEST_URI} !/admin/ [NC] #we are not in the admin panel
RewriteCond %{HTTP:Accept-Language} ^it [NC] #browser language is italian
RewriteRule ^(.*)$ http://domain.net/it/$1 [L,R=301]
#redirect to /en for all other langs
RewriteCond %{HTTP_HOST} ^domain\.net$ [NC]
RewriteCond %{REQUEST_URI} !/it/ [NC] #doesn't have /it in the url already
RewriteCond %{REQUEST_URI} !/en/ [NC] #doesn't have /en in the url already
RewriteCond %{REQUEST_URI} !/admin/ [NC] #we are not in the admin panel
RewriteRule ^(.*)$ http://domain.net/en/$1 [L,R=301]
This way all the conditions are checked, and if the language is italian they get a redirect to /it Otherwise the second block enter in action and they get redirected to the english version.
My first question is: there is a more efficient way to do this? my htaccess capabilities are very limited.
as an additional question: can this create problem with SEO? I guess all the bots that crawl domain.net are going to be redirected to the english version, then find the link (it's a flag image) to the italian version and crawl the italian version also. is it correct?