Heim  >  Fragen und Antworten  >  Hauptteil

Fragen zur Nginx-Konfiguration

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

nginx-Teile ist wie folgt:

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

Entschuldigung, Meister. Ich möchte auf http://domain.com zugreifen und nginx leitet es an das Indexverzeichnis weiter.

过去多啦不再A梦过去多啦不再A梦2713 Tage vor379

Antworte allen(3)Ich werde antworten

  • 黄舟

    黄舟2017-05-16 17:22:37

    这样配置会在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;
        }
        ……
    
    }

    Antwort
    0
  • 为情所困

    为情所困2017-05-16 17:22:37

    location /放最下面试试。

    Antwort
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 17:22:37

    location /admin/ {
        root /data/domain.com;
        index index.php index.html index.htm;
    }

    第二个 location 中的 root 多了 admin

    有问题先看日志。这种错误,看下 nginx 的日志就清楚了。

    Antwort
    0
  • StornierenAntwort