Routes[SOLVED]

#1
[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??

#2
[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);
    }

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

#4
[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";

#5
[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

#6
[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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.