Welcome Guest, Not a member yet? Register   Sign In
set default uri_protocol to PATH_INFO instead of AUTO
#1

[eluser]xwero[/eluser]
The trigger for this change is the continuously asked question : how to use the GET global in CI.

I think not clearing the GET global is only part of the solution because the AUTO setting has some odd behavior.
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) && count($_GET) == 1 && trim(key($_GET), '/') != '') {
   $this->uri_string = key($_GET);
   return;
}
This is the cause of headaches for many developers as their mixed segmented-query string url only often have one key-value pair in the query string.

I understand the framework should work out of the box but is it so hard to set an extra value to get the framework running. I think PATH_INFO is supported by most webservers nowadays.

What are your thoughts?
#2

[eluser]ThatBlokeRob[/eluser]
Hey, N00b question.

Where should I copy / paste this code in order for it to work?

Many Thanks,

Rob
#3

[eluser]BrianDHall[/eluser]
Have you tried enabling GET and setting the uri protocol to PATH_INFO in config.php? Works like a charm for me, though I have heard some people say it isn't working right for them.
#4

[eluser]ThatBlokeRob[/eluser]
Hey Brian,

How do I enable GET?
I set uri protocol PATH_INFO and that stopped getting to the error page, now just the home page.
How do I get it to view the page the browsers on?

Robin
#5

[eluser]BrianDHall[/eluser]
[quote author="ThatBlokeRob" date="1259188547"]Hey Brian,

How do I enable GET?
I set uri protocol PATH_INFO and that stopped getting to the error page, now just the home page.
How do I get it to view the page the browsers on?

Robin[/quote]

In config.php:

Code:
/*
|--------------------------------------------------------------------------
| Enable Query Strings
|--------------------------------------------------------------------------
|
| By default CodeIgniter uses search-engine friendly segment based URLs:
| example.com/who/what/where/
|
| You can optionally enable standard query string based URLs:
| example.com?who=me&what=something&where=here
|
| Options are: TRUE or FALSE (boolean)
|
| The other items let you set the query string "words" that will
| invoke your controllers and its functions:
| example.com/index.php?c=controller&m=function
|
| Please note that some of the helpers won't work as expected when
| this feature is enabled, since CodeIgniter is designed primarily to
| use segment based URLs.
|
*/
$config['enable_query_strings'] = TRUE;
$config['controller_trigger']     = 'c';
$config['function_trigger']     = 'm';

Now you could do ?c=controller&m=function and basically get rid of segment routing, but I like having both together, thus the use of PATH_INFO setting in config.php.

So now with the hybrid if it works properly you should be able to have website.com/controller/function?search=search+terms

And CI will handle everything as if there was no query string - only $GET will still be available everywhere, so you can access it directly and do whatever you like. Oh you may have to add some extra stuff to permitted_uri_chars so CI won't complain about the + sign and such.
#6

[eluser]ThatBlokeRob[/eluser]
Hey Brian,

Thank you for your help - that's cracked it!! Smile

Robin
#7

[eluser]dippy[/eluser]
How do i make this work with the index.php not in the url?

my .htaccess file:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php\?/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
    RewriteRule ^(.*)$ /index.php\?/$1 [L]
</IfModule>

every time it shows the home page.
#8

[eluser]dippy[/eluser]
any help here? i cant figure it out... it keeps bringing me back to the homepage even after i set the settings in config.php ....

is it my .htaccess file?
#9

[eluser]dippy[/eluser]
bump**




Theme © iAndrew 2016 - Forum software by © MyBB