Guest User

Untitled

a guest
Jul 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. //remember that custom routes need to go _after_ ci's default routes, as they're executed in the order you provide them
  2. $route['default_controller'] = "welcome";
  3. $route['404_override'] = '';
  4. //exception 1 to your regex here
  5. //exception 2 to your regex here
  6. //so on...
  7. $route['(:any)/(:any)/(:any)'] = "$2/$3/$1";
  8.  
  9. $route['([^/]+)/([^/]+)/([^/]+)'] = "$2/$3/$1";
  10.  
  11. $route['a/([^/]+)/([^/]+)/([^/]+)'] = "$2/$3/$1";
  12.  
  13. $route['(:any)/some_controller/method/'] = "some_controller/method/$1";
  14.  
  15. function method($my_param) {
  16. echo 'my param is '. $my_param;
  17. }
  18.  
  19. $route['(:num)/blog/entry/'] = "blog/view/$1";
  20.  
  21. class Blog extends CI_Controller {
  22.  
  23. function view($id) {
  24. echo 'fetching blog entry no ' . $id;
  25. }
  26. }
  27.  
  28. <html>
  29. <body>
  30. link to <?= anchor('1/blog/entry/','my first post'); ?>
  31. link to <?= anchor('2/blog/entry/','my second post'); ?>
  32. </body>
  33. </html>
Add Comment
Please, Sign In to add comment