I am writing a REST api in codeigniter using https://github.com/chriskacerguis/codeigniter-restserver REST controller library. I have written my controller inside application/controllers/api/v1 and override the Router class to allow multiple sub-folders inside controllers.
Now I want to access the services as http://api.domain.com/v1/user/11 instead of http://api.domain.com/api/v1/user/11
I have tried following htaccess rule
RewriteCond %{HTTP_HOST} ^api\.domain\.com$
RewriteCond %{REQUEST_URI} !index.php/
RewriteRule ^(.*)/?$ /index.php/api/$1 [QSA,L]
But it seems to be not working because REQUEST_URI in the $_SERVER global variable is set to v1/user/11 instead of api/v1/user/11 so codeigniter is unable to find the controller.
Is there a way to achieve the requirement except setting the altering REQUEST_URI in index.php?
I do NOT want to do permanent redirect.
Any help is much appreciated.