Welcome Guest, Not a member yet? Register   Sign In
$this->uri->segment() returns FALSE [SOLVED]


changed uri_protocol in config file to REQUEST_URI as discussed in this thread:



I hope someone can help! I am at my wits end.

I developed an application on my local machine and there were no issues with routing at all. I have uploaded to a live site and now I am not getting any information from the URI class at all. My entire app depends on the class!!

I have used a single controller for everything by routing:

$route['default_controller'] = "hub";
$route['scaffolding_trigger'] = "";
$route[':any'] = "hub";

Within the "Hub" controller I have used the _remap() function to route everything:

function _remap($method)
    //function is always segment 1 as there are no other controllers
    $method = $this->uri->segment(1);    //the function
    $var1 = $this->uri->segment(2);        //the page
    $var2 = $this->uri->segment(3);        //the first var
    $var3 = $this->uri->segment(4);        //the second var
    $var4 = $this->uri->segment(5);        //thrid var
    $var5 = $this->uri->segment(6);        //fourth var
    //changing the dash to an underscore for php
    $methodOrig = $method;
    $method = url_title($method, 'underscore', TRUE);
    //loads all the languages available through a folder search
    $languages = $this->lingua->dirContents(APPPATH.'/language/','folder');
    //changes the dash to an underscore (language codes have dashes - functions have underscores)
    foreach ($languages as $lang){
    $lang_array[] = url_title($lang, 'underscore', TRUE);
    $languages = $lang_array;
    $members = $this->common->regMembers();
    switch (true){
            //tests whether the requested url is a language rather than a function
            case (!empty($method) && in_array($method,$languages)):
            //assigns the function to segment 2 rather than 1 which is the language
            $function = $this->uri->segment(2,'index');            
            $function = url_title($function, 'underscore', TRUE);
            //tests wether the requested url is a valid function and calls the function
            case (!empty($method) && method_exists($this, $method)):
//user function            
case (!empty($methodOrig) && in_array($methodOrig,$newMemb)):
            //if all else fails - go to the index page

I have recently put the $method variable into the remap function brackets and when echoed, $method returns index rather than what is actually in the uri string. (index has been removed via mod_rewrite)

Every call to $this->uri->segment(#) returns FALSE.

Any ideas about what I have done wrong?? This is supposed to go live tomorrow morning!

Thanks everyone,

Well, I'm having a similar issue, however, I was already using REQUEST_URI and $this->uri->segment(any number) returns NOTHING.

Works fine on our local server with uri_protocol set to AUTO, but when uploading the site to Host Gator we have to change the protocol to REQUEST_URI or the site won't work.

Any help?

Hmm.. no one?

Theme © iAndrew 2016 - Forum software by © MyBB