'How to use standard , normal non pretty urls routing in framework Nette?
I want to use standard , not the pretty , nice , clean , neat urls routing in framework Nette as that way it is dependent on the apache httpd mod_rewrite module, which I don't have available , and pretty url is the default routing in Nette , how to accomplish it so no such url translation using mod_rewrite or nginx is necessary.
Solution 1:[1]
In Nette it is accomplishable not to use user-friendly pretty ('hezky' - original translation - ) urls, by using a simple router class , either
a newer way in configuration config.neon like
services: - Nette\Application\Routers\SimpleRouter('Homepage:default')instead of eg. a config item custom own router factory router: App\RouterFactory::createRouteror older one in bootstrap.php way used to be by automatic detection
// Setup router using mod_rewrite detection
if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules(), true)) {
$router = $container->getByType(Nette\Application\IRouter::class);
$router[] = new Route('index.php', 'User:default', Route::ONE_WAY);
$router[] = new Route('<presenter>/<action>[/<id>]', 'User:default');
} else {
$container->addService('router', new SimpleRouter('User:default'));
}
Afterwards urls are accessible by this format ?presenter=nameOfPresenter&action=nameOfAction, previously without it, it was accessible as /presenter/action.
source: https://doc.nette.org/en/application/routing#toc-simplerouter
analogically similarly as it used to be done in Yii framework by a configuration setting
'enablePrettyUrl' => true,
https://github.com/samdark/yii2-cookbook/blob/master/book/enable-pretty-urls.md#url-manager-configuration
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
