Welcome Guest, Not a member yet? Register   Sign In
[Closed] Codeigniter Will Not Load Default Route
#1

[eluser]riwakawd[/eluser]
Hello just a small issue codeigniter will not let me load my default route

$route['default_controller'] = "admin/admin_login/administrator";

I have tried many ways but no luck? Very strange.

To see full way I have done it can look at files here. https://github.com/riwakawebsitedesigns/ci-maintenance

I have added MY_Router but still nothing. Still will not load default route.
#2

[eluser]Massaki[/eluser]
First, you must be sure that your controller path is like this:

"project/application/controllers/admin/admin_login/administrator.php"


#3

[eluser]riwakawd[/eluser]
[quote author="Massaki" date="1397653123"]First, you must be sure that your controller path is like this:

"project/application/controllers/admin/admin_login/administrator.php"


[/quote]

Yes it is. Even On The Routes To. Just does not seem to work in sub subdirectory

#4

[eluser]Massaki[/eluser]
Can you call it normally? (http://yoursite.com/project/admin/admin_...inistrator)
#5

[eluser]Tpojka[/eluser]
I think your application/config/router.php is loaded before application/core/MY_Router.php so it can't see subfolders.
If I am right you have 2 level subfolders in controllers folder and CI by default can read only one.
#6

[eluser]riwakawd[/eluser]
[quote author="Tpojka" date="1397690883"]I think your application/config/router.php is loaded before application/core/MY_Router.php so it can't see subfolders.
If I am right you have 2 level subfolders in controllers folder and CI by default can read only one.[/quote]

I have found what I am after to solve my own issue http://stackoverflow.com/questions/21551...ollers-and

Get the right sub directories working. Latest version ci
#7

[eluser]riwakawd[/eluser]
Thought it worked I went to refresh page second time did not work very strange.
#8

[eluser]Tpojka[/eluser]
Clear the cache to make sure if (not) working.
#9

[eluser]riwakawd[/eluser]
[quote author="Tpojka" date="1397724936"]Clear the cache to make sure if (not) working.[/quote]

Still nothing so frustrated wont work even though names of controllers are correct. You would think codeigniter will be able to pick up controller / folder / folder / controller.php seems strange can not do that for default controller route.

I have CodeIgniter_2.1.4


Code:
<?php

class MY_Router extends CI_Router
{
    public function __construct()
    {
        parent::__construct();
    }

    public function _validate_request($segments)
    {
        if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
        {
            return $segments;
        }

        if (is_dir(APPPATH.'controllers/'.$segments[0]))
        {
            $this->set_directory($segments[0]);
            $segments = array_slice($segments, 1);

            while(count($segments) > 0 && is_dir(APPPATH.'controllers/'.$this->directory.DIRECTORY_SEPARATOR.$segments[0]))
            {
                // Set the directory and remove it from the segment array
                $this->directory = $this->directory . $segments[0] .DIRECTORY_SEPARATOR;
                $segments = array_slice($segments, 1);
            }


            if (count($segments) > 0)
            {
                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
                {
                    show_404($this->fetch_directory().$segments[0]);
                }
            }
            else
            {
                $this->set_class($this->default_controller);
                $this->set_method('index');

                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
                {
                    $this->directory = '';
                    return array();
                }

            }

            return $segments;
        }

        show_404($segments[0]);
    }
}

?>
#10

[eluser]Tpojka[/eluser]
Check this great explained article.
You can see that router.php is called before application/core classes. Therefore default CodeIgniter installation still don't use MY_Router.php during initializing default route. I said that in post before.




Theme © iAndrew 2016 - Forum software by © MyBB