最近在用cakephp开发小项目。发现一个问题,网上搜材料暂时没有找到解决方案,想要请教一下各位大牛。
cakephp 放在网站根目录下的/animal/文件夹中,所有URL都是
http://sample.com/animal/:controller/...
想要将其中一个controller的内容拿到上一级目录,例如将名为dog的controller改变成
http://sample.com/animal/dog/...
http://sample.com/dog/...
目前做法是修改根目录下的.htaccess 文件
<code>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]
</code>但是有一个问题,view中HtmlHelper中的链接仍然有/animal/,
Paginator也自动加有/animal/
<code>echo $this->Html->link(
'Dog',
array('controller' => 'dog', 'action' => 'smile')
);
URL: http://sample.com/animal/dog/smile
</code>如何在cakephp配置中修改此类问题?同时不影响其他controller的链接呢?
立即学习“PHP免费学习笔记(深入)”;
感谢感谢!!
最近在用cakephp开发小项目。发现一个问题,网上搜材料暂时没有找到解决方案,想要请教一下各位大牛。
cakephp 放在网站根目录下的/animal/文件夹中,所有URL都是
http://sample.com/animal/:controller/...
想要将其中一个controller的内容拿到上一级目录,例如将名为dog的controller改变成
http://sample.com/animal/dog/...
http://sample.com/dog/...
目前做法是修改根目录下的.htaccess 文件
<code>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]
</code>但是有一个问题,view中HtmlHelper中的链接仍然有/animal/,
Paginator也自动加有/animal/
<code>echo $this->Html->link(
'Dog',
array('controller' => 'dog', 'action' => 'smile')
);
URL: http://sample.com/animal/dog/smile
</code>如何在cakephp配置中修改此类问题?同时不影响其他controller的链接呢?
立即学习“PHP免费学习笔记(深入)”;
感谢感谢!!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号