I wonder should I rewrite URL using a .htaccess file or routes.php to get best performance. It also lead me to 2 different ways to get params.
.htaccess way:
<IfModule mod_rewrite.c> RewriteEngine On
RewriteRule ^hello/(.*)$ index/hello?name=$1 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
In controller:
$name = $this->request->get('name', 'string');
routes.php way:
<?php
/*
- Define custom routes. File gets included in the router service definition. */
$router = new Phalcon\Mvc\Router();
$router->add('/hello/{name}', array( 'controller' => 'index', 'action' => 'hello' ));
return $router;
In controller:
$name = $this->dispatcher->getParam('name', 'string');
Is there any hidden cons if I choose to rewrite url by using .htaccess?
Thank you in advance!