1. Go to this page and download the library: Download nette/routing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$params = $router->match($httpRequest);
if ($params === null) {
// no matching route found, we will send a 404 errorexit;
}
// we process the received parameters
$controller = $params['controller'];
...
// accepts both /hello and /hello.html, generates /hello
$router->addRoute('<name>[.html]', ...);
// accepts both /hello and /hello.html, generates /hello.html
$router->addRoute('<name>[!.html]', ...);
$router->addRoute('<controller=Homepage>/<action=default>/<id=>', ...);
// equals to:
$router->addRoute('[<controller=Homepage>/[<action=default>/[<id>]]]', ...);
$router = new Nette\Application\Routers\SimpleRouter();
<IfModule mod_rewrite.c>
RewriteEngine On
...
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
...
</IfModule>
// Will generate an HTTP address
$router->addRoute('http://%host%/<controller>/<action>', ...);
// Will generate an HTTPS address
$router->addRoute('https://%host%/<controller>/<action>', ...);