How can i remove /index in URL in routing in cakePHP?

不羁岁月 提交于 2019-12-25 04:55:12

问题


I want to remove /index in URL.

I have already tried the following in routes.php file :

 Router::connect('/Home/:index', array('controller' => 'Homes'));

and :

 Router::connect('/Home/', array('controller' => 'Homes','action'=>'index'));

回答1:


Try

Router::connect('/Home', array('controller' => 'Homes','action'=>'index'));



回答2:


Use this code for create link

<?php
echo $this->Html->link(__('YOUR_TEXT'),array('controller' => 'Homes', 'action' => 'index',array('class' => "", 'id' => ""));
?>

If you are creating link with this code then if is there any change made in routes then cakephp will update link according to that



来源:https://stackoverflow.com/questions/18603677/how-can-i-remove-index-in-url-in-routing-in-cakephp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!