我試圖nginx的到達路線的所有請求開始/嵌入到/home/forge/dev.tline.io/embed/index.php
Ngnix下載PHP
我的Nginx的配置:
location /embed {
root /home/forge/dev.tline.io;
try_files /embed/index.php =404;
}
location/{
root /home/forge/dev.tline.io;
index index.html index.htm;
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
所有請求去/embed/index.php
但不運行PHP文件下載它。
注:http://dev.tline.io/embed/index.php
編譯沒有下載
我得到它,如果添加
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
到location /embed
但應該有一個更好的方式來做到這一點
我已刪除從'location'裏面的'root',但它並沒有改變什麼,我已經有了一個'location'外的''root'定義 – Amitay
你把try_files放在php位置塊嗎? – Satys
我補充說,也沒有工作。 如果我將php位置代碼添加到/ embed塊中,它可以工作,但它的一個難看的解決方案 – Amitay