Codeigniter urls codeigniter user guide
CodeIgniter URLs CodeIgniter User Guide CodeIgniter User Guide Version CodeIgniter Home ?? User Guide Home ?? URLS Search User Guide Table of Contents Page Go CodeIgniter URLs By default URLs in CodeIgniter are designed to be search- engine and human friendly Rather than using the standard query string approach to URLs that is synonymous with dynamic systems CodeIgniter uses a segment-based approach example com news article my article Note Query string URLs can be optionally enabled as described below URI Segments The segments in the URL in following with the Model-View- Controller approach usually represent example com class function ID The ?rst segment represents the controller class that should be invoked The second segment represents the class function or method that should be called The third and any additional segments represent the ID and any variables that will be passed to the controller The URI Class 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 exibility Removing the index php ?le By default the index php ?le will be included in your URLs example com index php news article my article You can easily remove this ?le by using a htaccess ?le with some simple rules Here is an example of such a ?le using the negative method in which everything is redirected except the speci ?ed items https ellislab com codeigniter user-guide general urls html C CodeIgniter URLs CodeIgniter User Guide RewriteEngine on RewriteCond index php images robots txt RewriteRule index php L In the above example any HTTP request other than those for index php images and robots txt is treated as a request for your index php ?le Adding a URL Su ?x In your con ?g con ?g php ?le you can specify a su ?x that will be added to all URLs generated by CodeIgniter For example if a URL is this example com index php products view shoes You can optionally add a su ?x like html making the page appear to be of a certain type example com index php products view shoes html Enabling Query Strings In some cases you might prefer to use query strings URLs index php c products m view id CodeIgniter optionally supports this capability which can be enabled in your application con ?g php ?le If you open your con ?g ?le you'll see these items con ?g 'enablequerystrings' FALSE con ?g 'controllertrigger' 'c' con ?g 'functiontrigger' 'm' If you change enablequerystrings to TRUE this feature will become active Your controllers and functions will then be accessible using the trigger words you've set to invoke your controllers and methods index php c controller m method Please note If you are using query strings you will have to build your own URLs rather than utilizing the URL helpers and other helpers that generate URLs like some of the form helpers as these are designed to work with
Documents similaires










-
45
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Aucune attribution requise- Détails
- Publié le Dec 19, 2022
- Catégorie Law / Droit
- Langue French
- Taille du fichier 34.8kB