CodeIgniter Forums

Full Version: Strange behavior with routes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]fauria81[/eluser]
Hi everybody!

Im experiencing a strange behavior with CI's routes.

I have something like this in my config.php:

Code:
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/foo/';

And my routes.php looks like this:
Code:
switch($_SERVER['HTTP_HOST'])
{
    case 'foo.example.com':
        $route['default_controller'] = "directory/foo";
    break;
    case 'bar.example.com':
        $route['default_controller'] = "directory/bar";
    break;
    case 'baz.example.com':
        $route['default_controller'] = "directory/baz";
    break;
    default:
        $route['default_controller'] = "directory/foo";
    break;
}

$route['scaffolding_trigger'] = '';
$route['foo'] = "directory/foo";
$route['bar'] = "directory/bar";
$route['baz'] = "directory/baz";

$route['foo/(:any)'] = "directory/foo/$1";
$route['bar/(:any)'] = "directory/bar/$1";
$route['baz/(:any)'] = "directory/baz/$1";

$route['(:any)'] = "directory/foo/$1";

When i point at
Code:
http://www.example.com/
it goes to the correct "foo" view.

When i use
Code:
http://www.example.com/foo/bar
it goes again to the correct "bar" view.

Using
Code:
http://www.example.com/foo/baz
also works as expected.

But whenever i try
Code:
http://www.example.com/foo/foo
it does not work (broken link).

Any one knows why is this happening?

Thank you very much!

El Forum

[eluser]danmontgomery[/eluser]
foo/foo implies that you are trying to call the constructor, which doesn't work.