1

I have created a multilingual website with CodeIgniter and now I would like to change the default url www.myebsite.com into www.mywebsite.com/en/home.

How can I change it?

user4269288
  • 109
  • 2
  • 3
  • 10

3 Answers3

14

Navigate to application/config/routes.php

Find $route['default_controller']

And Replace to:

$route['default_controller'] = 'my-controller/my-method';
Ilanus
  • 6,690
  • 5
  • 13
  • 37
3

You can use the default controller to redirect to /en/home :

class Welcome extends CI_Controller {

    public function index()
    {
        redirect('en/home');
    }
}
mariek
  • 426
  • 4
  • 13
  • Hi Mariek, If I use redirect('en/home') in the default controller the page wil be redirected to www.mywebsite.com/en/home/en/home and not to www.mywebsite.com/en/home – user4269288 Aug 06 '15 at 10:26
  • 1
    it depends on your config. If the default route is "welcome/index", it will work, assuming "en/home" is not redirecting to "welcome/index". If the default route is already "en/home", you don't need to use a default controller. – mariek Aug 06 '15 at 13:02
1
$route['default_controller'] = 'my-controller/my-method';
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • While this code may solve the question, [including an explanation](https://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Dave Apr 05 '19 at 13:41