The directory structure is as follows:
root
└── data
└── domain.com
└── admin
└── index
The folder admin is the website backend webpage directory
The folder index is the website frontend directory
nginx part configuration is as follows:
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;
}
Access http://domain.com
is normal, but access http://domain.com/admin/
prompt 404
Could you please tell me how to set up http://domain.com nginx forwarding to the index directory and http://domain.com/admin/
nginx forwarding to the admin directory?
黄舟2017-05-16 17:22:37
With this configuration, you will find the admin under domain.com/admin
The configuration of root/index will generally be placed under the server, not in the location
Generally configured like this
server {
root /data/domain.com;
index index.php index.html index.htm;
location /{
try_files $uri $uri/ /index.php?s=$uri&$args;
}
……
}
phpcn_u15822017-05-16 17:22:37
location /admin/ {
root /data/domain.com;
index index.php index.html index.htm;
}
Second location
中的 root
多了 admin
.
If you have any questions, please read the log first. This kind of error will be clear after looking at the log of nginx
.