Home  >  Q&A  >  body text

Questions about nginx configuration

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梦2713 days ago376

reply all(3)I'll reply

  • 黄舟

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

    reply
    0
  • 为情所困

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

    location / put it at the bottom and try it.

    reply
    0
  • phpcn_u1582

    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.

    reply
    0
  • Cancelreply