Welcome Guest, Not a member yet? Register   Sign In
wrong controller in my first CI 3
#1

i just download CI and i take 2 folder application and system to my webfolder,
i move index.php to be inside application and i have modified the .htaccess

my webfolder is C:\onedrive\dropbox\template\
and my access url is http://localhost/template/application/index.php

but every time i open http://localhost/template/application/ always said :
404 Page Not Found, The page you requested was not found.

when i debugging to CodeIgniter.php
PHP Code:
var_dumpt($RTR->class); 
got
Code:
'template'

that why my url always wrong, why this is happened?

i just modify 'Router.php' in method '_set_request' in the first line to exclude my url for segmentation :
PHP Code:
        // akhyar : exclude url before index.php first
        
$excSegment explode('/',config_item('base_url'));
        
$segments array_diff($segments,array('index.php'));
        foreach (
$excSegment as $idxSegment => $valSegment) {
            
$segments array_values(array_diff($segments,array(urlencode($valSegment))));
        } 

become :
PHP Code:
    protected function _set_request($segments = array())
    {
        
// akhyar : exclude url before index.php first
        
$excSegment explode('/',config_item('base_url'));
        
$segments array_diff($segments,array('index.php'));
        foreach (
$excSegment as $idxSegment => $valSegment) {
            
$segments array_values(array_diff($segments,array(urlencode($valSegment))));
        }

        
$segments $this->_validate_request($segments);

        
// If we don't have any segments left - try the default controller;
        // WARNING: Directories get shifted out of the segments array!
        
if (empty($segments))
        {
            
$this->_set_default_controller();
            return;
        }

        if (
$this->translate_uri_dashes === TRUE)
        {
            
$segments[0] = str_replace('-''_'$segments[0]);
            if (isset(
$segments[1]))
            {
                
$segments[1] = str_replace('-''_'$segments[1]);
            }
        }

        
$this->set_class($segments[0]);
        if (isset(
$segments[1]))
        {
            
$this->set_method($segments[1]);
        }
        else
        {
            
$segments[1] = 'index';
        }

        
array_unshift($segmentsNULL);
        unset(
$segments[0]);
        
$this->uri->rsegments $segments;
    } 
Reply


Messages In This Thread
wrong controller in my first CI 3 - by SangPetualang - 09-16-2015, 08:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB