x中使用破折号的网址

x中使用破折号的网址

本文介绍了如何在Kohana 3.x中使用破折号的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有一个网址,例如

I need to have a URL such as http://example.com/controller/my-page-with-dashes

如何在Kohana中使用网址?我试着创建一个控制器,并命名操作 myPageWithDashes 像在Zend框架,但没有工作。

How can I have such as URL in Kohana? I tried creating a controller and name the action myPageWithDashes like in the Zend Framework but that didn't work. Any idea how it should be done?

推荐答案

复制文件 system / classes / kohana / request / client / internal.php 到您的应用程序文件夹 - application / classes / kohana / request / client / internal.php 。然后从

Copy the file system/classes/kohana/request/client/internal.php to your application folder - application/classes/kohana/request/client/internal.php. Then change line 106 from:

$action = $request->action();

到:

$action = str_replace('-', '_', $request->action());

这篇关于如何在Kohana 3.x中使用破折号的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:54