Redirect to language url with htaccess

0

I am working with CodeIgniter and I have implemented the multi-language to add different languages. Everything works perfect, the problem is that now mysite / and mysite / is have the same content. I want to redirect from my site / to my site / es but I can not get it.

This is my current htaccess file, now I am working in local:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Let's see if anyone can help me, thanks.

    
asked by Mathiew82 08.12.2016 в 19:33
source

1 answer

0

Fixed!

RewriteEngine on
RewriteBase /misitio/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteCond $1 !^index.php/(es|ca)/(.{0})$ [NC]
RewriteRule ^(.{0})$ es [R=301,L]

In this way, when you access the home without / is , you are redirected to the home with / is . For the rest of the pages, the site's own links are used to access the selected language.

    
answered by 17.12.2016 / 15:23
source