我正在使用CakePHP 2.3。我希望將舊頁面重定向到具有HTTP 301狀態的新頁面。現在我的網址看起來像http://www.example.com/profile/john和http://www.example.com/profile/john/shopCakePHP 2.3。 - 重定向301不起作用
我想的URL看起來像http://www.example.com/user/john和http://www.example.com/user/john/shop分別
我routes.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'? – noslone
是的,它應該被稱爲配置文件 - 約定。這可能是問題嗎? – vlcik
這可能是問題所在,你可以通過將''controller'=>'profile''改爲''controller'=>'profiles''來嘗試它。 – noslone