Codingox URLs¶
By default, URLs in Codingox 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, Codingox uses a segment-based approach:
example.com/blog/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 first 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 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:
example.com/index.php/blog/article/my_article
If your Apache server has mod_rewrite enabled, you can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the “negative” method in which everything is redirected except the specified items:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
In the above example, any HTTP request other than those for existing directories and existing files is treated as a request for your index.php file.
Note
These specific rules might not work for all server configurations.
Enabling Query Strings¶
In some cases you might prefer to use query strings URLs:
index.php/blog/article&id=345
Codingox already supports this capability, which can be use in your controller file.
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 segment based URLs.