Kohana路线使用错误的URL /主题模式

问题描述 投票:0回答:1

我正在尝试使用Kohana中的路由类将URL更改为另一个URL。

这是我的链接:

<a class="btn" target="_self" href="<?php echo URL::base(). $current_channel->name;?>/materials/28" title="Materials Download">
    <div class="txt">MATERIALS</div>
</a>

这给了我链接:localhost:8081/channel/materials/28,因为我正在使用php -S localhost:8081在本地服务器上运行>

这是我的路线规格:

Route::set('c_materials', '<channel_name>/materials(/<id>)',  array('channel_name' => $channel_names))
    ->defaults(array(
      'controller' => 'materials',
      'action'     => 'brands',
    ));
Route::set('materials', 'materials(/<id>)')
    ->defaults(array(
      'controller' => 'materials',
      'action'     => 'brands',
    ));

但是出于某种奇怪的原因,我无法弄清楚,Kohana在routes.php文件中找不到链接并抛出此错误:

ErrorException [ Warning ]: preg_match(): Compilation failed: unmatched parentheses at offset 50

查看错误日志,这是在preg_match中传递给Routes.php的参数:

pattern is "#^products/details(?:/(?P<id>[^/.,;?\n]++))?/update)?$#uD" but the subject is "channel/materials/28"

这是我第一次使用Kohana,所以我不知道为什么它使用这种奇怪的模式来匹配我的URL。这也在其他页面中发生,对于不同的URL使用相同的模式,这一直在破坏我的系统。

我尝试更改路由名称,强制路由仅接受materials/28处的URL,但由于此模式用于与我的URL比较而没有任何效果。我该如何更改?

我正在尝试使用Kohana中的路由类将URL更改为另一个URL。这是我的链接:

php kohana kohana-3 kohana-3.3
1个回答
0
投票

编辑:

© www.soinside.com 2019 - 2024. All rights reserved.