Views: 4818
Last Modified: 04.08.2023

Available starting from the Main version 21.400.0. Presently, Bitrix24 doesn't support custom modules employing their own routes in module folder.

  Launch

To launch a new system of routing, you need to forward processing of 404 errors to the file routing_index.php inside the file .htaccess:

#RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
#RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]

RewriteCond %{REQUEST_FILENAME} !/bitrix/routing_index.php$
RewriteRule ^(.*)$ /bitrix/routing_index.php [L]

Note: Starting from version 23.500.0, the router is connected via the method \Bitrix\Main\Application::getRouter().

  Configuration

Files with route configuration are located in the folders /bitrix/routes/ and /local/routes/. Connected file must be described in its .settings.php Bitrix Framework has several specific kernel settings without visual edit UI. This is done to prevent errors and setting update easily causing system crashes (database connection settings, caching settings and etc.).

Learn more ...
in routing section:

'routing' => ['value' => [
  'config' => ['web.php', 'api.php']
]], 

// connects the following files:
// /bitrix/routes/web.php, /local/routes/web.php,  
// /bitrix/routes/api.php, /local/routes/api.php

File format provides for returned closure, passed to the routing config object:

<?php

use Bitrix\Main\Routing\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
    // routes
};

Searches for matches in the same sequence, as described routes in the config.



Chapter contents:


Courses developed by Bitrix24