Cakephp路由前缀 [英] Cakephp routes prefix

查看:178
本文介绍了Cakephp路由前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个不同的布局,我的应用程序与不同部分的内容相关。
我想定义我的url,所以他们会有在开始ex的部分。 mypage.com/part1/controller / ...。
我不知道如何改变路线,使之成为可能。

I have 3 diferent layouts for my application related to diferent parts of content. I vould like to define my url-s so they would have the part in the begining ex. "mypage.com/part1/controller/...". I don't know how to change routes to make this possible.

我不想要普通的前缀路由,其中​​我的控制器操作的名称会改变。

P.S. I don't want ordinary prefix routing where names of my controller actions would have changed.

推荐答案

阅读下面的网址

对于CakePHP 2.x
http://book.cakephp.org/2.0/en /development/routing.html#prefix-routing

For CakePHP 2.x http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing

对于CakePHP 1.x
http://bakery.cakephp.org/articles/Frank/2009/11/02/cakephp-s路由解释

For CakePHP 1.x http://bakery.cakephp.org/articles/Frank/2009/11/02/cakephp-s-routing-explained

Configure::write('Routing.prefixes', array('admin', 'manager'));

$this->connect("/{$prefix}/:plugin/:controller", array('action' => 'index', 'prefix' => $prefix, $prefix => true));
$this->connect("/{$prefix}/:plugin/:controller/:action/*", array('prefix' => $prefix, $prefix => true));
Router::connect("/{$prefix}/:controller", array('action' => 'index', 'prefix' => $prefix, $prefix => true));
Router::connect("/{$prefix}/:controller/:action/*", array('prefix' => $prefix, $prefix => true));

这篇关于Cakephp路由前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆