问题
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