Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Case insesitive routing, how to?

How can I have case insesitive URL?

http://localhost:8188/login - OK

http://localhost:8188/logiN - Error 404, but I want to do loginAction ....

Thanks for help

Router settings

    $di->set ( 'router', function () {
        $router = new \Phalcon\Mvc\Router ( false );

        $router->add ( "/login", array (
                "controller" => "index",
                "action" => "login"
        ) );

        $router->add ( "/(.*)-{productid:[0-9]+}", array (
                "controller" => "products",
                "action" => "index" 
        ) );
        $router->notFound ( array (
                "controller" => "index",
                "action" => "route404" 
        ) );
        $router->setDefaults ( array (
                "controller" => "index",
                "action" => "route66" 
        ) );
        return $router;
    } );
edited Mar '14

You can setup your dispatcher to lowercase the route requests like this:

$di->set('dispatcher', function () {
    $events_manager = new \Phalcon\Events\Manager;

    $events_manager->attach('dispatch:beforeDispatchLoop', function ($event, $dispatcher) {

        if ($dispatcher->getActionName()) {


    $dispatcher = new \Phalcon\Mvc\Dispatcher;


    return $dispatcher;

I haven't verified that code 100% but it should work.


Doesn't work :(

edited Mar '14

My solution (after read a lot of Apache doc)

httpd.conf - add RewriteMap and enable proxy.

LoadModule proxy_module modules/
LoadModule proxy_http_module modules/

<VirtualHost *:8188>
DocumentRoot "C:/Eclipse 4 Workspace/phalcon/html/www/"
php_admin_flag engine On
RewriteMap lowercase int:tolower
    ProxyRequests On
    <Proxy *>
        Order deny,allow
        Allow from all


<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php?_url=/${lowercase:$1} [QSA,L,P]


You can add at the top of your index.php:

if (isset($_GET['_url'])) {
     $_GET['_url'] = strtolower($_GET['_url']);

edited Mar '14

It is working too, thank You.

Sorry about that. Glad to hear you got it working though, both by .htaccess and Phalcon's suggestion. :)