Guillaume Lavoie
Guillaume Lavoie

Reputation: 567

CodeIgniter - htaccess - Redirect

I am currently working with "Code Igniter" and the "i18n Multi-language Library Helper". My website is bilingual.

The simple task I want to do is to force redirect of this path:

domain.com/inscription

to

domain.com/fr/inscription

I tried to do it with CI Route Engine, but it it not working properly because the route engine will redirect to the current language ( ex. domain.com/en/inscription ), which should not work. Only domain.com/fr/inscription should work.

I believe the best way to do it if with the htaccess file, but I can't get it to work.

Upvotes: 1

Views: 474

Answers (2)

Grigor
Grigor

Reputation: 4049

Here is a code to redirect

# This allows you to redirect index.html to a specific subfolder 
Redirect /inscription http://domain.com/fr/inscription

the line under # comment line is the code you need to paste

Upvotes: 0

Altrim
Altrim

Reputation: 6756

If you are using Codeigniter 2.x try using this library

http://codeigniter.com/wiki/CodeIgniter_2.1_internationalization_i18n

Read the guide on how to set up the library and you can see there in MY_Lang.php file array like this. The first language in the array is the default one. So it will redirect you automatically to the default language

  // languages
private $languages = array(
    'en' => 'english',
    'de' => 'german',
    'fr' => 'french',
    'nl' => 'dutch'
);

Hope this helps

Upvotes: 1

Related Questions