CodeIgniter and GET Method working to-gether

This is a personal note kind of post.. So, those who knew already about this… just can skip.. :) . But for a short summary, to use the power of GET method by not setting the CI as Query string based URL. 

Target To achieve: 

http://localhost/myapp/mycontroller/mymethod/?possible=yes

create file MY_Input.php in your application/library/
[ Reason: SO that CI does not destroy GET Method ] 

<?php
class MY_Input extends CI_Input {
    function _sanitize_globals()
    {
        $this->allow_get_array = TRUE;
        parent::_sanitize_globals();
    }    
Change following variable in your Config.php 
$config['permitted_uri_chars'] = ‘a-z 0-9~%?=&.:_\-’;
$config['index_page'] = “”;
.htaccess File [ Thanks to Adnan ]
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 
Some Workaround: 
1. If you want to accept GET data in your controller’s index method.. have to use 
http://localhost/myapp/mycontroller/index/?possible=yes
Reference:
It worked out fine for me. My CI version is : 1.6.3

2 Comments »

  1. Sagive SEO said

    do you know how to aprove it in a wordpress ?

  2. tohin said

    I haven’t experimented and worked much with wordpress .. i am drupal guy :) .. but will give it a try in my off time. will let you know.

RSS feed for comments on this post · TrackBack URI

Leave a Comment