| htaccess | Codeigniter select language |

0

I use codeigniter as a framework, it is not a web page created by me, what I would like to know, is if it is possible to redirect a person to your language when you enter the website.

The issue is that to change the language, the website uses this:

<a href="javascript:void(0)" onclick="setLanguage('español', this)" class="current_language">
  </a>

So, I can not find a way for the web to redirect the user when it enters its corresponding language, because the web is using a public function that is located in the internal handler of the web and this function does is update with a query the database and put the language in the database, then it's not a URL, my idea was to have used this htaccess:

RewriteEngine On

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

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

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

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

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

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

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

But let's go, since there is no url path that changes the language, I have no idea how to do it and this .htaccess does not work.

Thank you, best regards.

    
asked by Vicente Juan Martí 08.12.2017 в 13:55
source

0 answers