Using codeigniter in QUERY_STRING mode with php fast CGI |
Hello,
I need to use codeigniter in QUERY_STRING mod ($config['uri_protocol'] = 'QUERY_STRING') because of my hosting. Indeed, my hosting use php fastcgi mod. So, on my config file I have this : PHP Code: $config['uri_protocol'] = 'QUERY_STRING'; In my htaccess I have this : Code: RewriteRule ^(.*)$ index.php?/$1 [L] My rules and my website work fine but, I need also to use some query string in my urls. Because of using this rule : Code: RewriteRule ^(.*)$ index.php?/$1 [L] When I have a page url like this : test.html?data=dog $_GET is empty... I can't access to $_GET['data'] Do you have any solution for me ? Thank you.
why is this set to false? $config['enable_query_strings'] = FALSE;
Website: http://avenir.ro
And I set to TRUE, If i do
PHP Code: <?php redirect('admin/'); ?> It's not working because codeigniter go to this url http://site.com?admin/ instead of http://site.com/admin/
@Peter: For security reasons the $_GET items are sanitized, stored and then $_GET is emptied.
If you want to fetch a GET item, use the $this->input->get('data') method. @Avenirer: enable_query_strings is always set to false from the default Installation. The name maybe suggests that you can't use urls like test.html?data=dog. But this setting has nothing to do with that. If you set this setting to true, you choose NOT to use segment based urls like example.com/controller/function but query string based urls example.com/index.php?c=controller&m=function.
The $this->input->get('data') change nothing, is still empty.
I use this controler : PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); This config : PHP Code: $config['uri_protocol'] = 'QUERY_STRING'; And this htaccess : Code: Options +FollowSymlinks My website is on php fastcgi hosting. $_GET[] and $this->input->get('data') are still empty when I am trying this url : http://site.com/site/test?data=mydata Thank you.
ok, a print_r() of $_GET will give you an empty array because CI stores the data from $_GET elsewhere and empties $_GET as explained.
But you should be able to fetch de GET items using $this-input->get('var name'); I tested this just now with this simple function: Code: function getitnow() { and when using the url Code: mydomain.com/test/getitnow?data=hello%20world CI echoed 'Hello world' as a result (03-20-2015, 09:29 AM)RogerMore Wrote: ok, a print_r() of $_GET will give you an empty array because CI stores the data from $_GET elsewhere and empties $_GET as explained. I use CI since 3 years and I know that but try to use CI with $config['uri_protocol'] = 'QUERY_STRING'; with my htaccess on a php fastcgi hosting, It doesn't work...
I use fcgid and use the same htaccess you are (with the ?), AND use query strings (and superglobal $_GET is available and populated). The only difference I see is I have mine set like:
PHP Code: $config['uri_protocol'] = 'REQUEST_URI'; I'm using CI 2.2
OK, guys. I think I'm missing the point here.
The uri_protocol setting is used to tell CI which server global holds your URI string. So if your server needs you to set te uri_protocol to QUERY_STRING it should be fine, but it doesn't require you to use GET variables. You'll still use regular /controller/method URI's. And why would you consider to set the enable_query_strings to true if not using the ?c=controller&m=method way of working...? This maybe a strange question: But are you sure your server runs Apache server? I had some similar problems when trying to make things work on a server running NGINX... |
Welcome Guest, Not a member yet? Register Sign In |