Celeroo Frame comes with a simple URL routing mechanism to rewrite your URLs so they are more search engine friendly (or if you simply want to hide the exact script names and parameters you use). It uses a .htaccess file and requires mod_rewrite to be enabled on your server.
If you don't want to use URL routing, you are free to remove the .htaccess file or comment out the rewrite rules. Disabling the routing mechanism will not cause any issues to the other parts of the framework.
The URL routing mechanism contains only two rules which are sufficient to handle every URL request to the framework. Instead of requiring you to remember complex URL rules, it gives you full power to represent GET arguments as folders.
|
| The rules |
The .htaccess comes with 2 ready rules:
- RewriteRule ^([^/]*)/(.*)/$ index\.php?action=$1&celeroo_request=$2
- RewriteRule ^([^/]+)/$ index\.php?action=$1
|
As a result of the first rule, example.com/action/ will be translated to example.com/index.php?action=action, i.e., the first directory in the URL corresponds to a controller name.
|
For example:
example.com/user/ will translate to example.com/index.php?action=user
and
will load user.php controller
and
example.com/contact/ will translate to example.com/index.php?action=contact and will load contact.php controller. |
The second rule handles everything else by letting you add unlimited pairs of parameters and values as folders:
example.com/action/param1/value1/param2/value2/param3/value3/ will be translated to example.com/index.php?action=action¶m1=value1¶m2=value2¶m3=value3
|
So for example:
example.com/user/do/edit/ will call example.com?action=user&do=edit
and
will load user.php controller passing a GET parameter "do" with value "edit"
and
example.com/ads/do/edit/id/5/ will call example.com?action=ads&do=edit&id=5 and will load ads.php controller passing GET pramaters "do" with value "edit" and "id" with value "5"
|
Note that all URL routes require a trailing slash at the end.
|
If you prefer to use the basic URL routing we provided in the earlier version, you can comment out the above rules and uncomment the original ones in .htaccess file. The basic .htaccess came with 2 ready rules:
- RewriteRule ^(.*)-(.*)\.html$ index\.php?action=$1&do=$2
- RewriteRule ^(.*)\.html$ index\.php?action=$1
|
This means the following:
action-subaction.html will be translated into index.php?action=action&do=subaction
OR:
users-add.html will be translated into index.php?action=users&do=add
action.html will be translated into index.php?action=action
OR:
register.html will be translated into index.php?action=register
etc.
Note that the exact syntax of the rewrite rules (mostly the backward and forward slashes) may differ on your server.
If you want to add more complex rules (for pagination, passing ids etc), you need to add them yourself.
|
|
 |
| |
| Need Help? Click here to send us your queries on the framework and/or the manual, and we will respond promptly. |
| |