嗨,在匹配Kohana 3自定义路线时,我有问题,似乎每件事都是正确的,但URL与路线匹配。以下是我的bootstrap.php文件中的设置:

   Kohana::init(array(
'base_url'   => '/basepath/',
    'index_file' => 'index.php'
  ));

  /**
  * Attach the file write to logging. Multiple writers are supported.
  */
  Kohana::$log->attach(new Log_File(APPPATH.'logs'));

  /**
  * Attach a file reader to config. Multiple readers are supported.
  */
   Kohana::$config->attach(new Config_File);

   /**
   * Enable modules. Modules are referenced by a relative or absolute path.
   */
   Kohana::modules(array(
'auth'       => MODPATH.'auth',       // Basic authentication
// 'cache'      => MODPATH.'cache',      // Caching with multiple backends
// 'codebench'  => MODPATH.'codebench',  // Benchmarking tool
'database'   => MODPATH.'database',   // Database access
'image'      => MODPATH.'image',      // Image manipulation
'orm'        => MODPATH.'orm',        // Object Relationship Mapping
// 'unittest'   => MODPATH.'unittest',   // Unit testing
'userguide'  => MODPATH.'userguide',  // User guide and API documentation
));


      /**
      * Set the routes. Each route must have a minimum of a name, a URI and a set of
      * defaults for the URI.
      */
    Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
    'controller' => 'welcome',
    'action'     => 'index',
));

    Route::set('category_images', 'cat/<category>', array('category'=>'[a-z\-_\.]+'))
->defaults(array(
    'controller' => 'categoryimages',
    'action'     => 'index',
));

     Route::set('user_images', '<username>/images(/<pageid>)', array('username'=>'[a-z\-_\.]+', 'pageid'=>'[1-9][0-9]*'))
->defaults(array(
    'controller' => 'userimages',
    'action'     => 'index',
));




     Route::set('dynamic_image', 'image/thumbnail/<size>/<id>/<image>', array('size'=>'s|m|z', 'id'=>'[0-9]+', 'image'=>'.+'))
->defaults(array(
    'controller' => 'image',
    'action' => 'thumbnail'
));
.

附件是错误mesage:

这里是目标控制器,如果存在以下问题,则显示命名约定:

<?php

class Controller_Categoryimages extends Controller_Template {

    public $template = 'template';
public $images_per_page = 15;

// show images of a user
    public function action_index() {
       //code here
     }
.

请告诉我们是否有任何想法,为什么它与URL不匹配。

在提前感谢。

有帮助吗?

解决方案

您的默认路由应持续,因为它是一个捕获全部。我建议你完全删除它。它目前匹配默认匹配,并尝试使用Action Sky加载conderer_cat类。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top