cakePHP 2.x重定向

cakePHP 2.x重定向,php,cakephp,cakephp-2.0,Php,Cakephp,Cakephp 2.0,第一个链接重定向到POST,如“localhost/posts”,但另一个链接没有重定向到“localhost/albus”,而是重定向到“localhost/app/webroot/albus/” 是的,专辑有索引页 守则: <?php echo '<li><a href="/posts">Posts</a></li>'; ?> <?php echo '<li><a href="/album

第一个链接重定向到POST,如“localhost/posts”,但另一个链接没有重定向到“localhost/albus”,而是重定向到“localhost/app/webroot/albus/”

是的,专辑有索引页

守则:

<?php
    echo '<li><a href="/posts">Posts</a></li>';
?> 
<?php 
    echo '<li><a href="/albums">albums</a></li>';
?> 

检查是否存在CakePHP应用程序未执行的重定向,即。E在
.htaccess
文件中

如果在
.htaccess
中指定
RewriteBase
有效,请尝试

/.htaccess

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase    /
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /app/webroot/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

重新启动发动机
重写基/
重写规则^$app/webroot/[L]
重写规则(*)app/webroot/$1[L]
/app/webroot/.htaccess

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase    /
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /app/webroot/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

重新启动发动机
重写base/app/webroot/
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]

您可以使用Cakephp语法来帮助您重定向必须重定向的操作,而不是使用普通的HTML

根据您的代码,应该可以工作,但您必须在虚拟主机中定义一些规则。 简单的解决方案使用php语法

例如:

<?php echo $this->Html->link(__('Album List'), array(
 'controller' => 'alubms', 
 'action' => 'index'),
 array('title'=>'<title>','class' => <class_if_any>));
?>


您有专辑控制器吗?我想您有
postController
albums
webroot
中的一个文件夹?是的,我有albumsController,我有两个控制器。我在WebRoot中没有albums文件夹您是否添加了任何针对albums的路由?不,我不太确定在这种情况下如何实现,但问题是为什么我的localhost/posts工作正常,而localhost/albums不工作