Redirect to subdomain in .htaccess using Accept-language

Popular automatic website translation tool

Redirect to subdomain in .htaccess using Accept-language

Postby freebouba » Tue Dec 27, 2016 9:44 am

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.
freebouba
 
Posts: 15
Joined: Tue Dec 27, 2016 8:24 am

Re: Redirect to subdomain in .htaccess using Accept-language

Postby Edvard » Tue Dec 27, 2016 8:37 pm

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!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4247
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Redirect to subdomain in .htaccess using Accept-language

Postby freebouba » Wed Dec 28, 2016 6:09 am

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.
freebouba
 
Posts: 15
Joined: Tue Dec 27, 2016 8:24 am

Re: Redirect to subdomain in .htaccess using Accept-language

Postby Edvard » Wed Dec 28, 2016 8:24 am

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!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4247
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Redirect to subdomain in .htaccess using Accept-language

Postby freebouba » Wed Dec 28, 2016 8:53 am

Hi,

Ok it's understood.

Thanks for quick reply.
freebouba
 
Posts: 15
Joined: Tue Dec 27, 2016 8:24 am

Re: Redirect to subdomain in .htaccess using Accept-language

Postby Edvard » Wed Dec 28, 2016 10:04 am

You are welcome!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4247
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia


  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest

2GLux