WebBasic CMS


The router serves to redirect HTTP requests to the appropriate controllers. To configure the router, use the file /router.ini, which specifies redirections for existing controllers. You can add your redirects by modifying the /router.ini file

The router parses the HTTP request, fills the array $ _ENV ["route"] in accordance with the described rules, and passes control to the specified controller. The controller gets control, parses the array $ _ENV ["route"], and performs the required actions.

Example 1 :

The HTTP request http://myserver.loc/mypage should display the mypage page. To do this, the following line is present in the router configuration:
/(:any) => /controller:form/mode:show/form:pages/item:$1/

  • /(:any) - the request pattern, indicates that the URL is followed by any character set. The pattern value will be assigned to $1 , since this is the first pattern filter;
  • => - indicates that there is a further redirection to the controller;
  • controller:form - specifies the form controller name
    $ _ENV ["route"] ["controller"] = "form";
  • mode:show - specifies the display mode of the data
    $ _ENV ["route"] ["mode"] = "show";
  • form:pages - specifies the name of the form (table) from which the data is displayed
    $ _ENV ["route"] ["form"] = "pages";
  • item:$1 - specifies the name of the record in the form (table) that you want to display. $1 is a variable taken from the pattern /(:any)
    $ _ENV ["route"] ["item"] = "mypage";

This HTTP request http: //myserver.loc/mypage will call the controller form and give it an array of parameters $ _ENV ["route"]: