Skip to content

Instantly share code, notes, and snippets.

@joshhartman
Created July 5, 2011 21:59
Show Gist options
  • Select an option

  • Save joshhartman/1066067 to your computer and use it in GitHub Desktop.

Select an option

Save joshhartman/1066067 to your computer and use it in GitHub Desktop.
Modify CodeIgniter to Support Hyphens in URL Request Segment
<?php
/*
|
| Put this file (MY_Router.php) inside /application/core (CI2)
| Remember that this will effect all segments, not only module, controller and method.
|
| Alternative to this extend is to add each segment to application/config/routes.php
| $route['this-is-a-module-or-controler'] = 'this_is_a_module_or_controller';
|
| As you can see the extend method would be easier to use. You can choose to make
| the function also to handle only the first two or three segments so that the other
| segments are not affected with the '_' replacement.
|
*/
class MY_Router extends CI_Router
{
function _set_request($segments = array()) {
parent::_set_request(str_replace('-', '_', $segments));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment