I'd like nginx to rewrite any http://api.example.org/xyz
requests to actually call example.org/api/xyz
behind the scenes. The tricky part too is that I'm using CodeIgniter so rather than load a php script at /xyz/index.php I'll need it to reference CodeIgniter's /index.php with the XYZ controller. Right now I have it set up like this:
if ($host = "api.example.org") {
rewrite ^(.*)$ http://example.org/api$1 permanent;
}
...but that causes a noticeable redirection to occur in the browser. I want the rewrite to be seamless/occur behind the scenes. So I tried:
if ($host = "api.example.org") {
rewrite ^(.*)$ /api$1 last;
}
But that gives me a "No input file specified" error. :( Has anyone tried rewriting a subdomain into a codeigniter controller on nginx before?
Thanks!