2016-01-22 37 views
0

我試圖建立一個項目我工作無限參數Nginx的API配置

我現在的nginx的conf快速臨時API:

listen 80; 
server_name app.domain.com 

root /var/www/html/public; 
index index.html index.php: 

rewrite ^/api/v1/([^/]+)/([^/]+)/?$ /apiv1.php?class=$1method=$2? last; 

location/{ 
    try_files $uri $uri/ /index.php; 
} 

+ standard fpm config 

儘管這適用於像URL/API/V1 /類型/子類型,

我需要能夠要求在這樣的格式網址:

/API/V1 /組織/ {ID} /支

/API/V1 /組織/ {ID} /團隊/ {ID}

我怎樣才能得到我的URL的參數可能無限量?

回答

1

用PHP解析URL比使用Nginx更容易。你可以創建一個location來處理所有的「/ api/v1」請求,並且proxy_pass把它們處理到apiv1.php,而後者將完成所有的工作。