Redirect CakePHP 2 urls to 4

Hello upgrading time, from 2 to 4 :wink:

But I have question about redirection form old url to new format.

Example:

CakePHP 2:

Router::connect('/satovi/:id-:slug/*', array('controller'=>'watches','action'=>'view','id' => '[0-9]+'),array('pass' => array('id','slug'),'id' => '[0-9]+'));

This generate link like:

https://detas.ba/satovi/7555-Tissot_T101_917_11_116_00

Now we are in upgrading process, and we want all old incoming get request redirect to new url format.

example: …/satovi/tissot/t101-917… etc

Please recommend the most painless solution, from the SEO point of view.

Do you want the URLs to all change, or are you just thinking that they have to? Because it seems like it should be possible to keep them the same, if you want to.

Yes, I want to redirect old URLs to new ones with code 302. Best place for such actions is middleware or router? Thanks.

The lowest server overhead place to do redirection is in .htaccess. Should be quite possible with regex matching.

1 Like

Hallo, thanks for your help