首页 > cakephp controller URL修改

cakephp controller URL修改

最近在用cakephp开发小项目。发现一个问题,网上搜材料暂时没有找到解决方案,想要请教一下各位大牛。

cakephp 放在网站根目录下的/animal/文件夹中,所有URL都是
http://sample.com/animal/:controller/...

想要将其中一个controller的内容拿到上一级目录,例如将名为dog的controller改变成
http://sample.com/animal/dog/...
http://sample.com/dog/...

目前做法是修改根目录下的.htaccess 文件

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.[^/\.]+$
RewriteRule .* %{REQUEST_URI}/ [L,R]

RewriteRule ^dog/(.*)/ animal/dog [L]
RewriteRule ^dog/(.*) animal/dog [L]

但是有一个问题,view中HtmlHelper中的链接仍然有/animal/,
Paginator也自动加有/animal/

echo $this->Html->link(
    'Dog',
    array('controller' => 'dog', 'action' => 'smile')
);
URL: http://sample.com/animal/dog/smile

如何在cakephp配置中修改此类问题?同时不影响其他controller的链接呢?

感谢感谢!!

【热门文章】
【热门文章】