this is my nginx configuration file
server {
listen 90;
server_name localhost;
root /var/www/wypok/;
index index.php index.html index.htm;
location / {
if ($request_uri = /) {
return 301 /mirkoplusy;
}
try_files $uri $uri/ @rewriteToMirkoplusy;
}
location @rewriteToMirkoplusy {
return 301 /mirkoplusy;
}
location ~* /mirkoplusy {
rewrite (?i)^/mirkoplusy/wpis/(.*)/(css|js|fonts)/(.+)/?$ /mirkoplusy/$2/$3;
rewrite (?i)^/mirkoplusy/wpis/(.*)/?$ /mirkoplusy/;
}
location ~* /api {
rewrite (?i)^/api/v(\d+)/(.+)/?$ /mirkoplusy/api/v$1/main.php?_url=/$2;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
The problem is that php files are not executed under the api directory. When I connect to http://localhost:90/api/v2/init I get back the source code of my main.php file which is called by the rewrite rule
location ~* /api {
rewrite (?i)^/api/v(\d+)/(.+)/?$ /mirkoplusy/api/v$1/main.php?_url=/$2;}
I created test.php file under the main root and it works so there must be some problem in that rewrite rule. Genreally I want every api call like /api/v2/entry/23224 to be passed to /api/v2/main.php file.