CakePHP redirect routing -


in cakephp 2.3 application, want example.com/come/harry redirect example.com/myworks/people/harry.

this works, connects.

router::connect ('/come/:myname',     array('controller' => 'myworks', 'action' => 'people'),     array(         'pass' => array('myname')     ) ); 

i need 301 redirection. tried this:

router::redirect ('/come/:myname',     array('controller' => 'myworks', 'action' => 'people'),     array(         'pass' => array('myname')     ) ); 

but redirected example.com/myworks/people/. how can pass argument action while redirecting ?

per the documentation want use persist rather pass redirects. code should work want:

router::redirect ('/come/*',     array('controller' => 'myworks', 'action' => 'people',           '?' => array('processed' => 1)),     array(         'persist' => array('myname')     ) ); 

the reason because you're generating new url when redirect:

  • pass used define of routed parameters should shifted pass array. adding parameter pass remove regular route array. ex. 'pass' => array('slug')
  • persist used define route parameters should automatically included when generating new urls. can override persistent parameters redefining them in url or remove them setting parameter false. ex. 'persist' => array('lang')

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -