Welcome Guest, Not a member yet? Register   Sign In
SEO URIs *AND* $_GET requests - /controller/function/?myvar=1
#20

[eluser]Pygon[/eluser]
yingyes:

I'm a bit confused as to how you are attempting to make this work because your description is vague. In fact, I'm not sure why you would even be posting anything here if you are using enable_query_strings as true, since that would completely bypass any of my code.

xwero:

My appologies -- try only: index.php/some/segment/?one=1 and you should recieve a 404 since CI_URI assumes that if count($_GET) == 1, the first key is the name of the base controller you would like to access:

CI_URI.php
Code:
// If the URL has a question mark then it's simplest to just
// build the URI string from the zero index of the $_GET array.
// This avoids having to deal with $_SERVER variables, which
// can be unreliable in some environments
if (is_array($_GET) AND count($_GET) == 1)
{
    $this->uri_string = key($_GET);            
    return;
}

However, from what you've said, and reviewing the code, I've realized that CI_URI could simply be modified.

Using enable_query_strings = true and uri_protocol = auto, GET requests should work perfectly fine as long as there is more than one GET variable.

I suspect if CI_URI was extended and that section of code commented out, everything should work the same, although I haven't exactly determined WHY this zero index thing would be done anyway.

Could be accomplished with:
$config['enable_query_string'] = true;
$config['uri_protocol'] = 'AUTO';

MY_URI.php
Code:
<?php
class MY_URI extends CI_URI {
    var $_backup_get;
    
    function MY_URI()
    {
        parent::CI_URI();
    }
    
    function _fetch_uri_string()
    {
        if (is_array($_GET) AND count($_GET) == 1)
        {
            $this->_backup_get = $_GET;
            $_GET = array();
            parent::_fetch_uri_string();
            $_GET = $this->_backup_get;
            return;
        }
        parent::_fech_uri_string();        
        return;
    }
}
?>

course you lose the "single _GET not using _SERVER variable performance benefit" thing.


Messages In This Thread
SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - by El Forum - 03-05-2008, 12:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB