【发布时间】:2014-05-05 00:08:33
【问题描述】:
我正在使用 Cakephp 2.3。我想将旧页面重定向到具有 HTTP 301 状态的新页面。现在我的 URL 看起来像 http://www.example.com/profile/john 和 http://www.example.com/profile/john/shop
我希望 URL 分别看起来像 http://www.example.com/user/john 和 http://www.example.com/user/john/shop
我的路由.php
Router::connect(
'/profile/:profile_name',
array(
'controller' => 'profile',
'action' => 'index',
),
array (
'pass' => array('profile_name')
)
);
Router::connect(
'/profile/:profile_name/shop',
array(
'controller' => 'profile',
'action' => 'shop'
),
array(
'pass' => array('profile_name')
)
);
我的重定向是:
Router::redirect(
'/user/:profile_name',
array(
'controller' => 'profile',
'action' => 'index',
),
array (
'persistent' => true,
'status' => 301
)
);
Router::redirect(
'/user/:profile_name/shop',
array(
'controller' => 'profile',
'action' => 'shop',
),
array (
'persistent' => true,
'status' => 301
)
);
但它不起作用。 404页面还在显示
我尝试按照教程中的说明进行操作,但没有任何效果
【问题讨论】:
-
你的控制器不是叫
ProfilesController吗? -
是的,它应该被称为 Profiles - 约定。会不会是问题?
-
可能是这个问题,你可以把
'controller' => 'profile'改成'controller' => 'profiles'试试