2014-03-26 2 views
0

저는 Cakephp 2.3을 사용하고 있습니다. 이전 페이지를 HTTP 301 상태의 새 페이지로 리디렉션하고 싶습니다. 이제 내 URL은 http://www.example.com/profile/johnhttp://www.example.com/profile/john/shop처럼CakePHP 2.3. - 리디렉션 301이 작동하지 않습니다.

내가 http://www.example.com/user/johnhttp://www.example.com/user/john/shop처럼 보이도록 URL을하고 싶습니다

각각

내 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 페이지가 아직도 내가이 튜토리얼하지만 아무것도에 설명 된대로 일을하려고했다

게재되어 작동

+1

밤은 컨트롤러? – noslone

+0

예, 프로필 - 대회라고해야합니다. 문제가 될 수 있습니까? – vlcik

+0

그게 문제가 될 수 있는데,''controller '=>'profile''을''controller '=>'profiles''로 변경하면 시도해 볼 수 있습니다. – noslone

답변

0

내가 ','더 있기 때문에 그것은 생각합니다.

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'))); 

여기에 같은`ProfilesController`라는

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 
    ) 
); 
+0

죄송합니다. ? – vlcik

+0

ok, 'action'=> 'index', <- 여기, 어쩌면 내가 문제 일 수는 없지만,이 경우에는 그렇지 않을 수도있는 쉼표가 있습니다 : Router :: connect ('profile', 'action'=> 'index', array ('패스'=> 배열 ('프로필 이름'))))); – CoolLife

관련 문제