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?
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
location / put it at the bottom and try it.
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
.