0

I have the following directory structure:

mysite.com - /api (codeigniter RESTful API Server) - /app (backbonejs app) 

I'm trying to configure NGINX to point all requests for mysite.com/api* to the api directory and use Codeigniter's setup.

Everything i've found works fine, if CI is in the root directory. But, the moment you try to put it in a sub-directory, it fails.

This is what I currently have:

server { listen 80; server_name local.mysite.com; root /Users/me/Sites/mysite; autoindex on; index index.html index.php; location /api { try_files $uri $uri/ /api/index.php; location ~ \.php$ { root /Users/me/Sites/mysite/api; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } } 

Doing this just gives me a 'File not found' error. Not even a proper nginx 404. How do I configure NGINX for CodeIgniter in a subdir of a server?

Thanks!

1 Answer 1

1

For anyone else who is trying to figure this out, and failing because no answer is out there yet, here is a super simple setup:

140 server { 141 listen 80; 142 server_name local.mysite.com; 143 root /Users/me/Sites/mysite; 144 autoindex on; 145 index index.html index.php; 146 147 location /api { 148 try_files $uri $uri/ /api/index.php$args; 149 150 } 151 152 location ~ \.php$ { 153 fastcgi_pass 127.0.0.1:9000; 154 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 155 include fastcgi_params; 156 } 157 158 159 160 } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.