最近在用cakephp开发小项目。发现一个问题,网上搜材料暂时没有找到解决方案,想要请教一下各位大牛。
cakephp 放在网站根目录下的/animal/文件夹中,所有URL都是
http://sample.com/animal/:controller/…
想要将其中一个controller的内容拿到上一级目录,例如将名为dog的controller改变成
http://sample.com/animal/dog/…
http://sample.com/dog/…
目前做法是修改根目录下的.htaccess 文件
<code>Options +FollowSymLinksRewriteEngine onRewriteCond %{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的链接呢?
感谢感谢!!
%本文@来源gao@!dai!ma.com搞$$代^@码!网搞代gaodaima码
回复内容:
最近在用cakephp开发小项目。发现一个问题,网上搜材料暂时没有找到解决方案,想要请教一下各位大牛。
cakephp 放在网站根目录下的/animal/文件夹中,所有URL都是
http://sample.com/animal/:controller/…
想要将其中一个controller的内容拿到上一级目录,例如将名为dog的controller改变成
http://sample.com/animal/dog/…
http://sample.com/dog/…
目前做法是修改根目录下的.htaccess 文件
<code>Options +FollowSymLinksRewriteEngine onRewriteCond %{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的链接呢?
感谢感谢!!