php - ZF2 Routing with Special Characters -


i have little question regarding routing zend framework 2. urls "normal" letters working fine , sides, example url characters á or whitespaces /test/some characters /test/héllo won't work , 404-error. when remove whitespaces in url or replace special character é normal "e" url too.

so think problem in module.config.php constraints. how can define these special characters reach urls? hope can me!

module.config.php url segment

'chemistry' => array(     'type' => 'segment',     'options' => array(         'route' => '[/:id[/:name]]/chemistry/page[/:page]',         'constraints' => array(             'id'    => '[0-9]*',             'name'  => '[a-za-z][a-za-z-]*',             'page'  => '[0-9]*'         ),         'defaults' => array(             'action'=> 'chemistry',             'id'    => '1',             'name'  => 'messi',             'page'  => '1'         ),     ), ), 

you using regex in route constraints. if want match route segments should change regex constraint accordingly. if want match route segment space character have add regex:

  • to match spaces anywhere in segment:

    '[a-za-z ]+'

  • to match words spaces in between.

    '[a-za-z]+( [a-za-z]+)*'

you can read more on regex in routing here in paragraph zend\mvc\router\http\regex in chapter routing


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -