Welcome Guest, Not a member yet? Register   Sign In
Replace underscore (_) with dashes (-) in URL
#11

[eluser]TheFuzzy0ne[/eluser]
My fault... The file should be called MY_Router.php, not Router.php.

If we call it Router.php, CodeIgniter assumes you want to override the library, instead of extending it, so it doesn't load the base class.
#12

[eluser]livewirerules[/eluser]
the function doesnt seem to be replacing the underscores. Other than placing that file in the core, do i have to load anything else separately?
#13

[eluser]TheFuzzy0ne[/eluser]
No, you shouldn't need to load anything else. Try sticking a big, fat die() in the code somewhere, and see if it's really be loaded.

Code:
class MY_Router extends CI_Router
{
    function __construct()
    {
        die('Woohoo! It\'s working! Sorta...');
    }

    // ...

If it's not working, maybe you've changed the prefix in your configuration file? By default, it should be:
Code:
$config['subclass_prefix'] = 'MY_';
#14

[eluser]TheFuzzy0ne[/eluser]
I think we might be misunderstanding each-other here. Other than using a 301 header, the URL won't change. All this does, is change how the URL is perceived by CodeIgniter. For example, if you had the following controller:
Code:
class Foo_bar extends CI_Controller
{
    function bar_foo()
    {
        // Imagine some code here.
    }
}

Normally, the URL to access it would be something like:

http://example.com/foo_bar/bar_foo

but with my modifications this should work, too:

http://example.com/foo-bar/bar-foo




Theme © iAndrew 2016 - Forum software by © MyBB