removeExtraSlashes not removing the ending slash from URL

i have this code in my routes.php file (app/config/routes.php)

<?php

$router = new Phalcon\Mvc\Router(true);

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

$router->removeExtraSlashes(true);

return $router;

However, if I type

http://localhost/myproject/contact-us/

into the browser

the url will remain the same and the last slash is not removed.

I want this

http://localhost/myproject/contact-us

How to do that? Why is $router->removeExtraSlashes(true); not working as it was supposed to?

The worst part is that The user can type something like that: http://localhost/myproject/contact-us/////// and the slashes won't be removed ;(



23.3k

That's weird. It's not working for me. The routes and caching of them is so weird on my WAMP machine (windows). Could it be that?

Hi @Phalcon, @Flanex I have the same problem with removing extra slash. Currently I use PHP 5.5.13, Phalcon 1.3.2, Windows 7 SP1 64 bit. I guess that there are some problems with Windows binary distribution and it works only on Linux.



85.0k

Just to clarify, not sure if there is a misunderstanding here, this actually does not remove the slashes from the URL (what the user sees on the url bar in the browser), this removes the slashes from the uri handled by the router.

http://localhost/myproject/contact-us// is handled as http://localhost/myproject/contact-us but the URL is the same in the browser.



23.3k
edited Jul '14

Ok, so how to remove the trailing slashes in browser url bar in Phalcon then, if removeExtraSlashes is not for that purpose?