[英]Nginx subdomain: redirecting to wrong directory
我有一個域(將其設置為example.com )。 另外,我有一個已配置的Nginx Web服務器,其中example.com指向根目錄/ var / www / example 。 然后,我想將service.example.com指向/ var / www / example ,然后將原始example.com指向/ var / www / service的 Nginx配置的Fisrt行,用於service.example.com,如下所示:
server {
server_name service.example.com;
root /var/www/example;
......
它有效,當我嘗試訪問service.example.com時,我被重定向到/ var / www / example中的索引文件。
然后,我為example.com進行了配置:
server {
server_name example.com www.example.com;
root /var/www/service;
......
,但是當我嘗試訪問example.com時 ,會看到/ var / www / example的索引文件-就像我試圖訪問service.example.com一樣 。
因此,如何解決此問題,並在嘗試訪問example.com時看到/ var / www / service的索引文件?
server {
root /var/www/service;
server_name service.example.com;
}
參考: https : //hackprogramming.com/how-to-setup-subdomain-or-host-multiple-domains-using-nginx-in-linux-server/
問題出在符號鏈接中。
其中一些不是啟用站點的符號鏈接,而是歸檔文件。 因此,nginx沒有處理它們。
問題解決了!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.