Part of the EllisLab Network

Bug Report

Default Controller Routing

Date: 06/06/2008 Severity: Major
Status: Resolved Reporter: priyank
Version: 1.6.2
Keywords: Libraries, Router Class

Description

=================================================
PROBLEM
=================================================
Well if the Default Controller in the config is set to be a controller in some subdirectory of the controller dir it returns an error…

Eg:

The Controller Directory Structure :
Controller -> Frontpage ->Frontpage.php

& now i Want this frontpage.php to be my default Controller :

$route[‘default_controller’] = “frontpage/frontpage”;

This Finally creates an 404 error as the $class variable on line 170 of codeigniter/codeigniter.php
gets set to “frontpage/frontpage” and hence Class Frontpage/Frontpage does not exist.

Hope this is found useful….

Regards

Priyank

Code Sample

=================================================
Solution
=================================================

However if we replace following section in libraries/Router.php the above problem can be resolved....
its line number 93 to 111 in libraries/Router.php

=================================================

// Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
/*        if ($this->uri->uri_string == '')
        {
            if ($this->default_controller === FALSE)
            {
                show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
            }
        
            $this->set_class($this->default_controller);
            $this->set_method('index');
            $this->_set_request(array($this->default_controller, 'index'));
            
            // re-index the routed segments array so it starts with 1 rather than 0
            $this->uri->_reindex_segments();
            
            log_message('debug', "No URI present. Default controller set.");
            return;
        }
*/    


=================================================

with the following code

=================================================

        if (
$this->uri->uri_string == '')
        
{
            
if ($this->default_controller === FALSE)
            
{
                show_error
("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
            
}
            $this
->uri->uri_string = $this->default_controller;
        
}

=================================================

Expected Result

Actual Result

Comment on Bug Report

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?