Die Verzeichnisstruktur ist wie folgt:
root
└── data
└── domain.com
├── admin
└── index
Der Ordner admin ist das Backend-Webseitenverzeichnis der Website.
Der Ordnerindex ist das Frontend-Verzeichnis der Website
Die Konfiguration der
location / {
root /data/domain.com/index;
index index.html index.htm;
}
location /admin/{
root /data/domain.com/admin;
index index.php index.html index.htm;
}
Besuchen http://domain.com
正常,但是訪問http://domain.com/admin/
提示 404
這樣配置會在domain.com/admin 下面找admin的
root/index 的配置一般都會放在 server下面的,不要放在location中
一般這樣配置好了
server {
root /data/domain.com;
index index.php index.html index.htm;
location /{
try_files $uri $uri/ /index.php?s=$uri&$args;
}
……
}
location /admin/ {
root /data/domain.com;
index index.php index.html index.htm;
}
第二個 location
中的 root
多了 admin
。
有問題先看日志。這種錯誤,看下 nginx
的日志就清楚了。