I’m using uri_protocol “AUTO”. The .htaccess looks like this:
RewriteRule ^(.*) index.php?/$1 [L]That works! key($_GET) has the entire query string including query parameters. However, the problem comes when I ask for the last segment in a uri that contains query parameters.
Eg:
http://www.example.loc/general/api/contributor_vote/json?vote=2&contributor_id=8
In the module method, I have this code:
$service = $this->EE->uri->segment(3);
$format = $this->EE->uri->segment(4);Problem I am getting is that $format contains this value:
json&vote=2&contributor_id=8
I really don’t want to do first(explode(‘&’, $this->EE->uri->segment(4))) because that is a hack. I’ve played around with .htaccess and the closest I could get was:
RewriteRule ^([^\?]*)(.*)$ index.php?$1 [L,QSA]But unfortunately this means that any uri with parameters now makes count($_GET) > 1 and CI decides it cannot use it due to this code:
// codeigniter/system/core/URI.php line 68 (CI_URI::_fetch_uri_string())
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')I’ve also tried all the other uri_protocols and had various issues with them too. REQUEST_URI would have been the one of choice, but EE_URI::_explode_segments() has a hard-coded rule to reject a uri with a question mark in it.
I’ve been tearing my hair out for two hours now trying to figure out how it is supposed to be done. Can someone tell me if it is possible to use both segments and query parameters without conflict, and what are the correct settings to achieve this?
Notice this has been moved from technical support to development and programming. I’m going to hack the core until I can discover whether a configuration exists that behaves as expected. Hmmm, I really did think a defectiveness in the product would have qualified for technical support.. I really hope this doesn’t require a phone call.
Ok, here’s my hack:
.htaccess
RewriteRule ^(.*) index.php?$1 [L,QSA]codeigniter/system/core/URI.php Line 68
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')becomes
if (is_array($_GET) && count($_GET) > 0 && trim(key($_GET), '/') != '')Please can someone tell me if there is a correct way to do this without altering the core.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.