0
votes

I have a small site based on Zend Framework 2.3 that runs on OS X with OS X Server. I need to do some development so I've copied it onto a Debian 7 system. Apart from the database definitions, the code is identical on both machines. The Linux-based system works for most functions but one results in a 404 error and I can't see why this should be. The module.config.php is array ( 'invokables' => array ( 'LibraryRest\Controller\AuthorRest' => 'LibraryRest\Controller\AuthorRestController', 'LibraryRest\Controller\BookTitleRest' => 'LibraryRest\Controller\BookTitleRestController', 'LibraryRest\Controller\RecentRest' => 'LibraryRest\Controller\RecentRestController' ), 'factories' => array ( 'LibraryRest\Controller\SearchRest' => 'LibraryRest\Factory\SearchRestControllerFactory' ) ), 'router' => array ( 'routes' => array (

                    'author-rest' => array (
                            'type' => 'Segment',
                            'options' => array (
                                    // Change this to something specific to your module
                                    'route' => '/author-rest[/:id]',
                                    'constraints' => array (
                                            'id' => '[0-9]+' 
                                    ),
                                    'defaults' => array (
                                            'controller' => 'LibraryRest\Controller\AuthorRest' 
                                    ) 
                            ) 
                    )
                    ,
                    'booktitle-rest' => array (
                            'type' => 'Segment',
                            'options' => array (
                                    'route' => '/booktitle-rest[/:id]',
                                    'constraints' => array (
                                            'id' => '[0-9]+' 
                                    ),
                                    'defaults' => array (
                                            'controller' => 'LibraryRest\Controller\BookTitleRest' 
                                    ) 
                            ) 
                    ),
                    'recent-rest' => array (
                            'type' => 'Segment',
                            'options' => array (
                                    'route' => '/recent-rest',
                                    'defaults' => array (
                                            'controller' => 'LibraryRest\Controller\RecentRest' 
                                    ) 
                            ) 
                    ),
                    'search-rest' => array (
                            'type' => 'Segment',
                            'options' => array (
                                    'route' => '/search-rest[/:action[/:first][/:last]]',
                                    'constraints' => array (
                                            'first' => '[a-zA-Z0-9_-\s\x40%\.]*',
                                            'last' => '[a-zA-Z0-9_-\s\x40%]*',
                                            'action' => '[a-zA-Z][a-zA-Z0-9_-]*' 
                                    ),
                                    'defaults' => array (
                                            'controller' => 'LibraryRest\Controller\SearchRest' 
                                    ) 
                            ) 
                    ) 
            ) 
    ),
    'view_manager' => array (
            'strategies' => array (
                    'ViewJsonStrategy' 
            ) 
    ) 

); The route that fails on the linux machine is search-rest, so http://mysite/search-rest/search/John/Smith results in a 404. All the other routes in this module work correctly on both systems.

What might be causing the routing to fail on the Linux system?

1
Probably a case sensitivity problem. Check the filename of your SearchRest controller.Tim Fountain

1 Answers

0
votes

Personally I would try by changing the regex for the first and last params :

'search-rest' => array (
        'type' => 'Segment',
        'options' => array (
            'route' => '/search-rest[/:action[/:first][/:last]]',
            'constraints' => array (
                'first' => '[a-zA-Z0-9_\-\s\x40%\.]*',
                'last' => '[a-zA-Z0-9_\-\s\x40%]*',
                'action' => '[a-zA-Z][a-zA-Z0-9_-]*'
            ),
            'defaults' => array (
                'controller' => 'LibraryRest\Controller\SearchRest'
                )
            )
        ),

I added a "\" just before the "-" or you can try by putting the "-" at the beginning of the character class ([]).

Because right now it generates an error in the ZF Segment class when calling the preg_match() function internally. As there is an error, it results in a 404 because the route could not be found.