如何从 URL 中删除索引操作?
这是我在 routes.php
中的代码
Router::connect('/jobs/:slug',array('controller'=>'jobs','action'=>'index'));
基本上,我有这个网址:
http://example.com/jobs/index/pharmacist
但我想把那个改成
http://example.com/jobs/pharmacist
这个配置是纯粹在 routes.php
中还是我需要编辑我的 .htaccess
,老实说我完全不知道。
非常感谢您的帮助。谢谢!
最佳答案
根据 Docs
通过使用 Router::connect()
的第三个参数,您可以定义哪些路由元素也应该作为传递参数可用:
Router::connect('/jobs/:slug',array('controller'=>'jobs','action'=>'index'), array('pass' => array('slug')));
在您看来,您可以使用
生成链接echo $this->Html->link('link', array(
'controller' => 'jobs',
'action' => 'index',
'slug' => 'your_slug'
));
关于php - CakePHP 从 URL 中删除索引操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24689042/