Codeigniter URLs
There are Codeigniter community designed URLs SEO friendly, Also human readable.
Rather than exploitation the quality “query string” approach to URLs that are synonymous with dynamic systems, CodeIgniter uses a segment-based approach:
URI Segments
The segments within the computer address, in following with the Model-View-Controller approach, usually represent:
- The primary phase represents the controller category that ought to be invoked.
- The second phase represents the category operate, or method, that ought to be known as.
- The third and any further segments represent the ID and any variables that will be passed to the controller.
The URI Library and therefore the computer address Helper contain functions that create it simple to figure together with your URI information.
In addition, your URLs will be remapped victimization the URI Routing feature for additional flexibility.
Removing the index.php file
If your Apache server has mod_rewrite enabled, you'll be able to simply take away this file by employing a .htaccess file with some easy rules.
Here is Associate in Nursing example of such a file, exploitation the “negative” technique during which everything is redirected except the desired items:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Note - These specific rules won't work for all server configurations.
Note - make certain to additionally exclude from the on top of rule any assets that you simply may be accessible from the surface world.
Adding a URL Suffix
In your config/config.php file, you'll specify a suffix that may be extra to any or all URLs generated by CodeIgniter.
For example, if a URL is this:
You would like optionally add a suffix, like .html, making the page appear to be of a certain type:
Enabling Query Strings
In some cases you would possibly favor using question strings URLs:
This Framework optionally supports this capability, which can be enabled in your application/config.php file.
If you open your config file you’ll see these items:
If you alter “enable_query_strings” to TRUE this feature can become active.
Your controllers and functions can then be accessible exploitation the “trigger” words you’ve set to invoke your controllers and methods:
Note - If you're exploitation question strings you'll need to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some
of the shape helpers,) as these are designed to figure with section primarily based URLs