在我的Nginx的網絡服務器,我有幾個虛擬主機是這樣的: - api.example.com - www.example.com - cv.example.comDebian的8 nginx的配置
但是當我訪問WWW .example.com/example,這不是一個有效的路徑,它給了我的api.example.com的404頁面。但爲什麼 ?
這是www.example.com我目前nginx的配置:
server {
listen 443 ssl;
listen [::]:443 ssl;
access_log /var/log/nginx/www.example.com-access.log timed;
error_log /var/log/nginx/www.example.com-error.log;
root /var/www/wwwexamplecom/html/_site;
server_name example.com www.example.com;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
location/{
index index.html index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/example/html/public/index.php;
include fastcgi_params;
}
location ~ /.well-known {
allow all;
}
}
這是我api.example.com的配置:
server {
listen 443 ssl;
listen [::]:443 ssl;
access_log /var/log/nginx/api.example.com-access.log timed;
error_log /var/log/nginx/api.example.com-error.log;
root /var/www/apiexamplecom/html/public;
server_name api.example.com;
include snippets/ssl-api.example.com.conf;
include snippets/ssl-params.conf;
location/{
index index.html index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/apiexamplecom/html/public/index.php;
include fastcgi_params;
}
location ~ /.well-known {
allow all;
}
}
我認爲自其在/位置的一部分,但我不是真的如何我可以解決這個問題。這也發生在其他虛擬主機上。
將此添加到我的wwwexamplecom nginx配置後,它沒有解決我的問題。 – Noob
嘗試在你的'try_files'節的末尾添加'= 404'例如:'try_files $ uri $ uri/..... = 404' – sharif9876
好吧,它現在可以工作,但我不是沒有爲什麼我必須添加= 404我的try_files結束 – Noob