Skip to content

Instantly share code, notes, and snippets.

@rnavarro
Created September 27, 2012 04:08
Show Gist options
  • Save rnavarro/3792098 to your computer and use it in GitHub Desktop.
Save rnavarro/3792098 to your computer and use it in GitHub Desktop.
server {
listen 81;
root /var/sites/app/webroot/;
server_name localhost;
rewrite_log on;
location ^~ /api/ {
rewrite /api/(.*)$ /$1 last;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
@gabrielfalcao
Copy link

did you try:

rewrite "/api/(.*)$" /$1 last;

instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment