Kevin Weber
Kevin Weber

Reputation: 198

301 Redirects with Cakephp

I am trying to 301 redirect a url to a new place since the original pages don't exist anymore. The URL I am trying to run is Guns/Rifles/Heckler_Koch/MP5_A4. I need this to redirect to Guns/Heckler_Koch/. I have tried so many things, but this is the only thing I could come up with and it doesn't work. When I run this it brings me to, manufacturers/items/. Thank you for your help.

Router::connect(
    '/Guns/:manufacturer', 
    array('controller' => 'manufacturers', 'action' => 'items'), 

    array('pass' => array('manufacturer'), 'routeClass' => 'GunRoute')
);


Router::redirect(
    '/Guns/Rifles/:manufacturer/*', 
    array('controller' => 'manufacturers', 'action' => 'items'),
    array('pass' => array('manufacturer'), 'status' => '301')        

);

Upvotes: 1

Views: 929

Answers (1)

Anubhav
Anubhav

Reputation: 1625

Router::connect(
    '/Guns/:manufacturer', 
    array('controller' => 'manufacturers', 'action' => 'items'), 
    array('persist' => array('manufacturer'), 'routeClass' => 'GunRoute')
);

Upvotes: 1

Related Questions