CodeIgniter Forums
nginx with base_url adds the base url - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: nginx with base_url adds the base url (/showthread.php?tid=67533)



nginx with base_url adds the base url - AmitMY - 03-06-2017

I'm trying to version my app, such that /0.0.1/ is the API for version 0.0.1, and so on.
My nginx rewrite for that is:

Code:
location / {
    try_files $uri $uri/ @rewrite;
}

location @rewrite {
    rewrite ^(/\d\.\d\.\d)(/.*)$  /stage/$1/api/index.php?q=$2&$args last;
    rewrite ^                     /index.php?q=$uri&$args last;
}


Which technically works, and reaches CI.
Going to this URL: "api.url.com/0.0.1/genders" for example, I get a 404.

Printing `$_GET` says there is one parameter, "q", with value "/genders";
Printing the uri segments gives me:
Quote:(
[0] => 0.0.1
[1] => genders
)

I tried setting `base_url` to "/0.0.1/" and also to the full path, but no luck, same segments that I think are causing a 404.

What am I doing wrong?


RE: nginx with base_url adds the base url - monkeyboy - 05-03-2017

Did you ever figure it out? I have the exact same problem.