Redirect to subdomain in .htaccess using Accept-language
Dec 27, 2016 5:44 am by freebouba
Dec 27, 2016 5:44 am by freebouba
Hi,
I'm using GTranslate enterprise and I wish to redirect to subdomain in .htaccess using Accept-language from user browser.
I'm using CDN cloudflare to.
I try in .htaccess the following code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-language} ^fr [NC]
RewriteRule ^$ http://fr.mydomain.com [L,R=301]
(Without => " rel="nofollow" target="_blank" information!)
However I have the following message:
Error too many redirect
I try this code to:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^fr.mydomain.com$ [NC]
RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule .* http://fr.mydomain.com [R,L]
(Without => " rel="nofollow" target="_blank" information!)
But i have the same result:
Error too many redirect
Please, can you help me to achieve this redirection.
Thanks.
Re: Redirect to subdomain in .htaccess using Accept-language
Dec 27, 2016 4:37 pm by Edvard
Dec 27, 2016 4:37 pm by Edvard
Hi,
We never suggest doing that. It confuses your visitors. If they come to your website from search engine results pages they will land on a correct language. If they come from links in other websites, they will also land on a correct language.
Thanks!
Re: Redirect to subdomain in .htaccess using Accept-language
Dec 28, 2016 2:09 am by freebouba
Dec 28, 2016 2:09 am by freebouba
Hi,
yes I understand that can confuses my visitors. However if I wish to do it, can you tell me how to do it?
Thanks.
Re: Redirect to subdomain in .htaccess using Accept-language
Dec 28, 2016 4:24 am by Edvard
Dec 28, 2016 4:24 am by Edvard
Hi,
In order to not create a redirect loop, you have to make sure that you do not redirect our server. For that you need to check if the request is from our network. You can do that by checking X-GT-Lang header which will be set if the request is from our network. Something like RewriteCond %{HTTP:X-GT-Lang} ^$.
Thanks!
Re: Redirect to subdomain in .htaccess using Accept-language
Dec 28, 2016 4:53 am by freebouba
Dec 28, 2016 4:53 am by freebouba
Hi,
Ok it's understood.
Thanks for quick reply.
Re: Redirect to subdomain in .htaccess using Accept-language
Dec 28, 2016 6:04 am by Edvard
Dec 28, 2016 6:04 am by Edvard
You are welcome!
SIMILAR TOPICS
Large numbers of crawl errors with double language code | Jan 24, 2019 1:43 am | Replies: 1 | Post by: natastna2 |
Translate website to any specific language, on page load | Jan 19, 2019 6:49 am | Replies: 1 | Post by: Leaon7756 |
Graphic translation for every language is missing | Dec 19, 2018 7:54 am | Replies: 1 | Post by: Daryl Dixon |
How to remove mobile Language Select Button transparency | Dec 5, 2018 10:06 pm | Replies: 10 | Post by: JeffTR |
Change language automatically | Nov 26, 2018 9:29 pm | Replies: 3 | Post by: Antilb |