[英]Catch-all configuration except for www.website.com?
通過使用Nginx,我試圖通過顯示特定的網站來配置服務器以使其接受指向服務器IP的所有域,但是在訪問www.example.com(主網站)時,我會顯示一個其他內容。
這是我到目前為止所做的:
server {
// Redirect www to non-www
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
// rest of the configuration
}
server {
// Catch all
listen 80 default_server;
// I also tried
// server_name _;
// Without any luck.
// Rest of the configuration
}
此配置的問題在於,對該服務器(不是www.example.com或example.com)的每個請求均采用example.com服務器配置,而不是全部捕獲。
我只想在前兩個配置中添加www.example.com/example.com,並在最后一個配置中添加所有其他內容。
我建議將您的服務器放在文件之上:)
我認為nginx希望默認服務器位於-a-文件之上。 我的服務器上確實有很多文件,但是有一個默認服務器作為第一個服務器聲明的文件,並且可以正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.