CodeIgniter Forums
Routes[SOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Routes[SOLVED] (/showthread.php?tid=31046)



Routes[SOLVED] - El Forum - 06-04-2010

[eluser]Ivar89[/eluser]
Hi,
I need my url to change and well I did it before and worked fine but I can't seem to do it anymoreTongue
rhis is my URL
http://ikwoon.ivi/main/view/Zuid-Holland
Main = controller
view = function
Zuid-Holland = var.

I need to get rid of the Main/view soit will look like this

http://ikwoon.ivi/Zuid-Holland

any help??


Routes[SOLVED] - El Forum - 06-04-2010

[eluser]Ivar89[/eluser]
This is the controllerSadif its needed):
Code:
function view($province)
    {
        $data['brokers'] = $this->main_model->get_brokers($province);
        //var_dump($data); exit();
        $this->load->view('main/view', $data, FALSE);
    }



Routes[SOLVED] - El Forum - 06-04-2010

[eluser]Ivar89[/eluser]
Solution:
Code:
$route['(?).:any'] = "main/view/$0";



Routes[SOLVED] - El Forum - 06-04-2010

[eluser]Simian Studios[/eluser]
Hi Ivar

Without knowing anything else about your app it's hard to decide the best course of action, but unless you have loads of other actions you want access to, a solution would be to just use config/routes.php to do the work for you.

e.g:

Code:
// define all other actions first
$route['example'] = "example/action";

// then this one will mop up any others
$route['(.*?)'] = "main/var/$1";



Routes[SOLVED] - El Forum - 06-04-2010

[eluser]Ivar89[/eluser]
Yhea I knew i wanted to do it with route but it didn't work but as you can see I figured it outWink

thanks anywayBig Grin


Routes[SOLVED] - El Forum - 06-04-2010

[eluser]Simian Studios[/eluser]
Heh, you solved it while I was on the phone mid-way through writing my post.. glad you sorted it anyways Smile


Routes[SOLVED] - El Forum - 06-04-2010

[eluser]Ivar89[/eluser]
aaaah, I see haha well thanks anywayTongue