Wednesday, 15 June 2016

CodeIgniter URLs

  • Human friendly
  • Search-engine
  • Standard “query string” approach
  • Dynamic systems
  • Segment-based approach
jayakumar.xyz/codeigniter/docs/urls

URI Segments

It is following MVC Approach
jayakumar.xyz/class/function/ID
  1. The first segment represents the controller class 
  2. The second segment represents the function (method) class
  3. The third segment represents the ids, variable or passing any variables class 
The URI Library and the URL Helper contain functions that make it easy to work with your URI data. In addition, your URLs can be remapped using the URI Routing feature for more flexibility


Removing the index.php file

By default, the index.php file will be included in your URLs:
jayakumar.xyz/index.php/codeigniter/docs/urls
If your Apache server has mod_rewrite enabled, you can easily remove this file by using a .htaccess file with some simple rules.

Example: .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

After using .htaccess file default url changed
jayakumar.xyz/codeigniter/docs/urls

Enabling Query Strings

In some cases you might prefer to use query strings URLs:
jayakumar.xyz/index.php?c=products&m=view&id=345
CodeIgniter optionally supports this capability, which can be enabled in your application/config.php file.

$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm'; 
jayakumar.xyz/index.php?c=controller&m=method 

No comments:

Post a Comment

Git merge branch to another branch

$ git checkout develop $ git pull $ git checkout test-branch $ git merge develop $ git push