如何将tld.com/bures/oceanfront转换为Kohana中的tld.com/articles/view/bures/oceanfront?

StackOverflow https://stackoverflow.com/questions/838161

  •  10-07-2019
  •  | 
  •  

我正在使用Kohana 2.3.2

我网站上的大多数(如果不是全部)链接都是文章。

我的控制器叫做文章,我有一个名为View的方法。我不想在/ articles / view /前面添加所有链接,所以我想设置一个默认控制器来处理所有文件。

我研究过使用默认路由器,这使得tld.com使用了Articles控制器。但是,当我尝试访问像/ bure / oceanfront /这样的东西时,我得到了Kohana的404错误。

我查看了这篇文章,但是我认为它已经过时了,因为给出的例子总是错误的(也看到指出这些的评论)。

有帮助吗?

解决方案

现在正在运作:

Event::add('system.post_routing' ,'call_fallback_page');



function call_fallback_page() {
        Router::$controller = 'Articles';
        Router::$method = 'index';
        Router::$controller_path = APPPATH.'controllers/articles.php';
}

来自问题中的教程。

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