I have two symbolic links that I cannot change on my example.com server, both redirecting to the same cake app:
- public_html/restapi/086 => /home/user/cake_app/webroot
- public_html/restapi/087 => /home/user/cake_app/webroot
My goal is to redirect:
- example.com/restapi/086 requests to my Api/V1 prefix
- example.com/restapi/087 requests to my Api/V2 prefix
This is what I’ve tried:
routes.php
$routes->scope('/', function (RouteBuilder $builder) {
$host = "example.com/restapi/086/";
$builder->connect('/', ['prefix' => 'Api/V1', 'controller' => 'V1', 'action' => 'index'])->setHost($host);
$host = "example.com/restapi/087/";
$builder->connect('/', ['prefix' => 'Api/V2', 'controller' => 'V2', 'action' => 'index'])->setHost($host);
}
This is not working since the host is only example.com and I shouldn’t include the full path there. How can I rewrite my code to make it work? Thanks in advance.