CodeIgniter Forums
Please help with routing problem! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Please help with routing problem! (/showthread.php?tid=11712)



Please help with routing problem! - El Forum - 09-20-2008

[eluser]Gewa[/eluser]
hi! routing in my application is not working , please help to fix ..

i need when i go to http://www.mysite.com/link/1865bd2d9bd6386de8396e0f98920d63
in my website, it to open /redirect controller, function go_to

and pass 1865bd2d9bd6386de8396e0f98920d63 as $name

I have controller redirect with function go_to($name)

so that the link http://www.mysite.com/link/1865bd2d9bd6386de8396e0f98920d63 will equall to http://www.mysite.com/redirect/goto/1865bd2d9bd6386de8396e0f98920d63

i added
Code:
$route['link/:any'] = "/redirect/goto";

to route.php, but the variable is not passing and i get
Code:
[b]$name variable is not set[/b]
error...
here is my full route.php
Code:
$route['default_controller'] = "start";
$route['scaffolding_trigger'] = "";

$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];

//put dlja redirecta

           $route['link/:any'] = "/redirect/goto";




//menjajem put dlja auth-php .



      $route['login'] = "auth";

      $route['login'] = "auth/login";

      $route['logout'] = "auth/logout";

      $route['register'] = "myaccount/register";

      $route['activate/:any'] = "auth/activation";
    $route['changepass'] = "auth/changepassword";

      $route['forgpass'] = "auth/forgotten_password";

      $route['resetpass/:any'] = "auth/forgotten_password_reset";

$route['myaccount/show/:num'] = "myaccount/show";

$route['myaccount/edit/:num'] = "myaccount/edit";
$route['admin'] = "admin/adminhome";
$route['admin/users/:num'] = "admin/users";
$route['admin/admins/:num'] = "admin/admins";



Please help with routing problem! - El Forum - 09-20-2008

[eluser]Pascal Kriete[/eluser]
Routes are regular expressions - you need a capture group in there:
Code:
$route['link/(:any)'] = "/redirect/goto/$1";



Please help with routing problem! - El Forum - 09-20-2008

[eluser]Gewa[/eluser]
oh thanks a lot!!!