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 
Reference:
It worked out fine for me. My CI version is : 1.6.3

Advertisements

5 thoughts on “CodeIgniter and GET Method working to-gether

  1. tohin says:

    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.

  2. saif says:

    Dear,
    if i use ‘&’ and ‘=’ in $config[‘permitted_uri_chars’] = ‘’; it shows error.
    also .htaccess file is not working…………showing ‘500 Internal Server Error’.

    My CI version is :1.7.1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s