Questions about nginx configuration
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 17:20:37
0
3
440

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?

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
黄舟

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;
    }
    ……

}
为情所困

location / put it at the bottom and try it.

phpcn_u1582
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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template