简体   繁体   中英

404 The requested URL could not be matched by routing

I'd just started to learn and following this user guide .

I'm able to successfully install the zend skeleton application and moved on to the routing and controllers . But after completion of the tutorial I requested the url: http://zf2-tutorial.localhost/album in my browser and I'm getting 404 .

I'd looked down into the comments where some people saying about changes in

'route' => '/album[/][:action][/:id]'

needs to be

'route' => '/album[/:action][/:id]'

but that doesn't help either. Can anyone help me in resolving the issue?

Directory structure:

zend应用程序目录结构

thanks to Crisp for mentioning the url in comment .

there is a missing link between zend skeleton application and routing and controllers where the initial module structure and module file code is written.

the code in my Module.php was missing is

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements AutoloaderProviderInterface, ConfigProviderInterface {
    public function getAutoloaderConfig()
     {
         return array(
             'Zend\Loader\StandardAutoloader' => array(
                 'namespaces' => array(
                     __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                 ),
             ),
         );
     }
    public function getConfig() {
        return include __DIR__ . '/config/module.config.php';
    }
}

Are you sure you set the Apache webserver to create a Virtual Host ( Learn how here )

Perhaps try going to localhost/album and see if that works, because by the information/routes given, this should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM